Advertising is a crucial revenue source for e-commerce platforms and a vital online marketing tool for their sellers. In this paper, we explore dynamic ad allocation with limited slots upon each customer’s arrival for an e-commerce platform, where customers follow a choice model when clicking the ads. Motivated by the recent advocacy for the algorithmic fairness of online ad delivery, we adjust the value from advertising by a general fairness metric evaluated with the click-throughs of different ads and customer types. The original online ad-allocation problem is intractable, so we propose a novel stochastic program framework (called two-stage target-debt) that first decides the click-through targets and then devises an ad-allocation policy to satisfy these targets in the second stage. We show the asymptotic equivalence between the original problem, the relaxed click-through target optimization, and the fluid-approximation ( Fluid ) convex program. We also design a debt-weighted offer-set algorithm and demonstrate that, as long as the problem size scales to infinity, this algorithm is (asymptotically) optimal under the optimal first-stage click-through target. Compared with the Fluid heuristic and its resolving variants, our approach has better scalability and can deplete the ad budgets more smoothly throughout the horizon, which is highly desirable for the online advertising business in practice. Finally, our proposed model and algorithm help substantially improve the fairness of ad allocation for an online e-commerce platform without significantly compromising efficiency. This paper was accepted by Jeannette Song, operations management. Funding: Y. Rong is supported by the National Natural Science Foundation of China [Grants 72025201, 72331006, and 72221001]. R. Zhang is grateful for the financial support from the Hong Kong Research Grants Council General Research Fund [Grants 14502722 and 14504123] and the National Natural Science Foundation of China [Grants 72293560 and 72293565]. H. Zheng is supported by the National Natural Science Foundation of China [Grants 72231003, 72325003, and 72221001]. Supplemental Material: The online appendix and data files are available at https://doi.org/10.1287/mnsc.2021.04091 .