We assess the prospects for ending AIDS in South Africa using a dynamical model to fit data on time trends in HIV prevalence and anti-retroviral treatment (ART) coverage for adults. We estimate current and project future trends in HIV incidence, prevalence and AIDS related deaths, in ART coverage and incidence, and in TB notification rates. We consider two scenarios: constant effort under which people continue to be started on treatment at the current rate and expanded treatment and prevention under which testing rates are increased, everyone is started on treatment as soon as they are found to be infected with HIV, and voluntary medical male circumcision, pre-exposure prophylaxis and condom distribution programmes are expanded. As a result of the roll-out of ART the incidence of HIV has fallen from a peak of 2.3% per annum in 1996 to 0.65% in 2016, the AIDS related mortality from a peak of 1.4% per annum in 2006 to 0.37% p.a. in 2016 and both continue to fall at a relative rate of 17% p.a. Maintaining a policy of constant effort will lead to further declines in HIV incidence, AIDS related mortality and TB notification rates but will not end AIDS. Implementing a policy of expanded treatment and prevention in September 2016 should ensure that by 2020 new infections and deaths will be less than one per thousand adults and the UNAIDS Goal of Ending AIDS by 2030 will be reached. Scaling up voluntary medical male circumcision, pre-exposure prophylaxis and condom availability will avert some new infections but will save relatively few lives. Nevertheless, equity demands that people at very high risk of infection including commercial sex-workers, men-who-have-sex-with-men and young women should have access to the best available methods of prevention. The current cost to the health services of managing HIV and TB among adults in South Africa is about US$2.1 Bn p.a. (0.6% of GDP p.a.) and this will rise to a peak of US$2.7 Bn p.a. in 2018 (0.8% GDP p.a.). As treatment is scaled up and prevention made available to those at high risk, the cost will fall to US$ 1.8 Bn p.a. in 2030 and US$ 1.0 Bn p.a. in 2050 as those that are living with HIV on ART, die of natural causes. The cost of testing people for HIV is never more than about 8% of the total cost and since testing is the sine qua non of treatment it will be essential to invest sufficient resources in testing. The cost of treating tuberculosis is never more than about 10% of the total and since this is the major cause of AIDS related illness and deaths, efforts should be made to optimise TB treatment. Ending AIDS in the world will depend critically on what happens in South Africa which accounts for 20% of all people living with HIV. The increasing availability of ART has had a major impact on both HIV incidence and AIDS related mortality and universal access to ART is affordable. With the commitment to make treatment available to all those infected with HIV in September 2016, the South African government is well placed to eliminate HIV as a major threat to public health by 2020 and to end AIDS by 2030. Individuals at high risk of infection deserve access to the best available methods of protecting themselves and they will become increasingly important in the final stages of ending the epidemic.