Millions of dollars are spent annually to prevent infection with human immunodeficiency virus (HIV) without a thorough understanding of the most effective way to allocate these resources. The authors' objective was to determine the allocation of new resources among prevention programs targeted to a population of injection drug users (IDUs) and a population of non-injection drug users (non-IDUs) that would minimize the total number of incident cases of HIV infection over a given time horizon. They developed a dynamic model of HIV transmission in IDUs and non-IDUs and estimated the relationship between prevention program expenditures and reductions in HIV transmission. They evaluated three prevention programs: HIV testing with routine counseling, HIV testing with intensive counseling, and HIV testing and counseling linked to methadone maintenance programs. They modeled a low-risk IDU population (5% HIV prevalence) and a moderate-risk IDU population (10% HIV prevalence). For different available budgets, they determined the allocation of resources among the prevention programs and populations that would minimize the number of new cases of HIV infection over a five-year period, as well as the incremental value of additional prevention funds. The study framework provides a quantitative, systematic approach to funding programs to prevent HIV infection that accounts for HIV transmission dynamics, population size, and the costs and effectiveness of the interventions in reducing HIV transmission. The approach is general and can be used to evaluate a broader group of prevention programs and risk populations. This framework thus could enable policy makers and clinicians to identify a portfolio of programs that provide, collectively, the most benefit for a given budget.