US President Barack Obama has met the family of South Africa's ailing anti-apartheid hero Nelson Mandela, offering words of comfort and praising the critically ill retired statesman as one of history's greatest figures.
The faltering health of Mandela, 94, a figure admired globally as a symbol of struggle against injustice and racism, is dominating Obama's two-day visit to South Africa.
But Obama also faced protests by South Africans against US foreign policy, especially American drone strikes.
Police fired stun grenades to disperse several hundred protesters who had gathered outside the Soweto campus of the University of Johannesburg, where Obama addressed an afternoon town hall meeting with students.
The brief confrontation some distance away did not disrupt the event in the heavily protected campus, where Obama gave a speech praising what he called a new "more prosperous, more confident" Africa. He also took questions from students.
On the second leg of a three-nation Africa tour, Obama met Mandela's relatives to deliver a message of support instead of directly visiting the frail former president at the hospital where he has spent the last three weeks.
The half-hour meeting took place at the Nelson Mandela Centre of Memory in Johannesburg.
Obama said afterwards in a statement he had also spoken by telephone with Mandela's wife Graca Machel, who remained by her husband's side in the hospital in Pretoria.
"I expressed my hope that Madiba draws peace and comfort from the time that he is spending with loved ones, and also expressed my heartfelt support for the entire family as they work through this difficult time," he said, using the clan name Madiba by which Mandela is affectionately known.
Machel said she had conveyed this message to her husband and thanked the Obamas for their "touch of personal warmth".
Obama earlier held talks with South African President Jacob Zuma and the two held a joint news conference in which Zuma said Mandela remained in a "critical but stable condition".
"We hope that very soon he will be out of hospital," Zuma added, without giving further details.
Obama's visit to South Africa had stirred intense speculation that the first African-American president of the United States would look in on the first black president of South Africa in his hospital room.
But Mandela's deterioration in the last week to a critical condition forced the White House to decide against such a visit.
"BOUND BY HISTORY"
Speaking to reporters at Pretoria's Union Buildings, where Mandela was inaugurated in 1994, Obama said the prayers of millions around the world were with the Nobel Peace laureate.
He likened Mandela to the first US president, George Washington, because both had decided to step down at the peak of their power and popularity.
"What an incredible lesson that is," Obama said, calling Mandela "one of the greatest people in history".
Obama said on Thursday he did not "need a photo op" with Mandela, whom he met in 2005 in Washington as a US senator.
Zuma underscored the historical similarities between Mandela and Obama. "The two of you are also bound by history as the first black presidents of your respective countries," Zuma said.
"You both carry the dreams of the millions of people in Africa and the diaspora."
On Sunday, Obama flies to Cape Town, from where he will visit Robben Island, the windswept former penal colony in the frigid waters of the south Atlantic where Mandela spent 18 of his 27 years in apartheid jails.
Zuma said Mandela had told him before his latest hospitalisation that "when I go to sleep I will be very happy because I left South Africa going forward".
Despite the protests of some against Obama, many other South Africans said they were inspired by the US leader's example.
"Obama, like Nelson Mandela, is the first black president in his country ... His success in the US shows that we as Africans can also make it," said Nanzwakazi Zuma, a lecturer in electrical engineering who attended the Soweto event.