Barack Obama was speaking in the executive capital, Pretoria, after talks with President Jacob Zuma.
Nelson Mandela, South Africa’s first black president, has been critically ill for nearly a week.
Earlier, Barack Obama said he would not visit the 94-year-old in hospital, but would meet his family in private.
The White House said the decision had been made “out of deference to Nelson Mandela’s peace and comfort and the family’s wishes”, but that Barack Obama and First Lady Michelle Obama would offer the Mandela family “their thoughts and prayers at this difficult time”.
President Jacob Zuma said the former leader remained “stable but critical”, but said he had “every hope that he will be out of hospital soon”.
In Pretoria, Barack Obama said Nelson Mandela’s example of “the power of principle, of people standing up for what’s right continues to shine as a beacon”.
“The outpouring of love that we’ve seen in recent days shows that the triumph of Nelson Mandela and his nation speaks to something very deep in the human spirit; the yearning for justice and dignity that transcends boundaries of race and class and faith and country,” he said.
Jacob Zuma said that as the first black leaders of their respective countries, Barack Obama and Nelson Mandela were “bound by history” and so “carry the dreams of millions of people in Africa and in the diaspora who were previously oppressed”.
The two leaders addressed a wide range of issues in their conversations, including trade and industry, conflicts in the region, efforts to tackle HIV/Aids and foreign affairs.
Jacob Zuma said Barack Obama’s visit was “well timed” to take advantage of a growing market in South Africa, and called for greater US investment.
He also said he believed the Africa National Congress (ANC), which he leads and which was founded by Nelson Mandela, was still “moving in the footsteps” of the former leader.
“I have no doubt that what we have been doing is part of what Mandela would be doing if he was here,” he said.
When asked whether the US felt threatened by the increasing influence of other countries, particularly China, in Africa, Barack Obama said he believed it was a good thing for the development of the continent, but cautioned South Africa to ensure that foreign companies were employing local workers and investing back into the country.
Barack Obama, who is travelling with his family, arrived in South Africa from Senegal on Friday evening.
During his weekend trip, the US president will visit Robben Island off Cape Town, where Nelson Mandela was imprisoned for 18 years. On Monday, he will continue his African tour in Tanzania.
Nelson Mandela is revered for leading the fight against white minority rule in South Africa and then preaching reconciliation despite being imprisoned for 27 years.
He was awarded the Nobel Peace Prize in 1993 and was elected president the following year. He left office in 1999 after a single term.
Nelson Mandela retired from public life in 2004 and has rarely been seen at official events since.
He has a long history of lung problems, and was diagnosed with tuberculosis in the 1980s while he was a prisoner on Robben Island.
After his release, Nelson Mandela said that the tuberculosis was probably caused by dampness in his prison cell.
-PwQAvn8W2YImage source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…