Microsoft co-founder and philanthropist Bill Gates delivers the Nelson Mandela Annual Lecture in Pretoria, South Africa, Sunday, July 17, 2016. Gates said that his foundation will invest another $5 billion in Africa over the next five years. (AP Photo)

Microsoft co-founder and philanthropist Bill Gates said Sunday his foundation will invest another $5 billion in Africa over the next five years.

Gates delivered the Nelson Mandela Annual Lecture ahead of Mandela Day, when South Africans are encouraged to donate 67 minutes of their time to help others.

Gates is also in South Africa to attend a global AIDS conference that starts Monday.

Gates said the Bill & Melinda Gates Foundation has already invested more than $9 billion in Africa. Health is a major focus.

Gates warned that if the world doesn't come up with more creative ways to make HIV treatment and prevention accessible, "the hard-earned gains made against HIV in sub-Saharan Africa over the last 15 years could actually be reversed" as high birth rates continue.

He said Africa is the world's youngest continent in terms of demographics. "By 2050, 40 percent of the world's children will live on this continent," he said.

Still, he said Africa had made notable progress in fighting AIDS, saying that the last time South Africa hosted the global conference 16 years ago, only a few thousand Africans were on HIV drugs. At the time, the drugs were too expensive for many in the region hardest hit by the epidemic.

Microsoft co-founder and philanthropist Bill Gates delivers the Nelson Mandela Annual Lecture in Pretoria, South Africa, Sunday, July 17, 2016. Gates said that his foundation will invest another $5 billion in Africa over the next five years. (AP Photo)

South Africa now says half of its infected population of 6.8 million people is on treatment.

Gates noted that Mandela fought stigma by announcing publicly the death of his son from AIDS in 2005.

Gates' speech focused largely on youth and on how to achieve ambitious global development goals endorsed by countries last year.

In the only sharp words of his address, he said: "I get angry when I see that Africa is suffering the worst effects of climate change, although Africans had almost nothing to do with causing it."

Explore further AIDS summit in S.Africa to warn of lagging effort

© 2016 The Associated Press. All rights reserved.