UNAIDS, and the WHO, plan to use “treatment as prevention” (TasP) to eliminate HIV. The rationale is that treating HIV-infected individuals reduces their infectivity. We present a novel geostatistical framework for implementing the rollout of TasP in sub-Saharan Africa. We focus on Lesotho, because UNAIDS has identified their epidemic as a priority for elimination. Our framework is based on a density of infection (DoI) map that we generate by gridding high-resolution demographic data, and spatially smoothing georeferenced HIV-testing data. The map reveals the geographic dispersion pattern of HIV-infected individuals, both diagnosed and undiagnosed. We use the map to design a treatment allocation strategy that optimizes, under resource constraints, the efficiency of resource utilization. Using this strategy (rather than the current treatment allocation strategy) would make it easier to find, diagnose and treat individuals. We also use our framework to evaluate the feasibility of UNAIDS’ elimination plan. We show the feasibility of reaching specific treatment coverage levels depends upon the geographic dispersion pattern of HIV-infected individuals, and that this pattern reflects the spatial demographics of Lesotho. Only 20% of HIV-infected individuals live in urban areas; most live in rural settlements where the DoI is less than six infected individuals/km2. Given these conditions, it will be almost impossible to reach a very high coverage of treatment. Therefore, the UNAIDS elimination plan is unlikely to succeed in Lesotho. Taken together, our results show that the spatial demographics of populations will significantly hinder, and may even prevent, the elimination of HIV in sub-Saharan Africa.