VERENA, South Africa — A fading roadside ad for Selala Funeral Service here captures what was, until recently, the essence of South Africa’s AIDS epidemic: “Tombstones Are Available,” it reads. “Buy One, Get One Free.”

Not long ago, even places like Verena, a blip on the roadside northeast of Pretoria, supported several funeral parlors.

But in the last few years, “we’ve managed a miracle,” said Dr. Salim Abdool Karim, one of the country’s leading AIDS researchers. “Undertaking is not a business you want to go into anymore.”

As recently as 2008, the AIDS epidemic in South Africa was out of control, hampered by the indifference of President Thabo Mbeki, Nelson Mandela’s successor. Death was everywhere.