President Jacob Zuma called former president Nelson Mandela "one of a kind" as tens of thousands of South Africans and the world's powerful gathered in Soweto, at a rain-drenched, rousing memorial for the globally loved liberation hero.
"That we are Madiba's compatriots and have lived during his time is a cause for celebration and enormous pride," Zuma said.
"He never lost his fighting spirit... He continued to inspire our people every single day from inside prison walls," Zuma said before recalling that Mandela's release from prison was one of the most moving moments in recent history.
"Everyone has had a Mandela moment when this world icon has touched their lives... There was no one like Madiba, he was one of a kind," he said.
"Today, the whole world stands still to pay tribute to Africa's greatest son. Rest in peace our father and our hero."
The speech drew to a close a four-hour memorial that gathered more than 90 foreign leaders, but took a humiliating turn for Zuma when large sections of the crowd booed him as the world watched.
The open hostility embarrassed the African National Congress, whose deputy leader Cyril Ramaphosa called for restraint, and which has tried to tap into Mandela's legacy as it prepares for general elections next year under a cloud of controversy about Zuma's homestead at Nkandla in KwaZulu-Natal.
ANC spokesman Jackson Mthembu said the party was shocked that the event had been politicised.
"We are not happy at all. We would have preferred that all who attended this ceremony gave Madiba a well-deserved send-off. It came as a bolt to all of us."
The crowd's reaction to Zuma marked a sharp contrast to the applause given to former president Thabo Mbeki and US President Barack Obama.
The US leader arrived late, but delivered a eulogy that dominated the day, describing Mandela as one of the great liberators of the last century.
"To the people of South Africa, people of every race and every walk of life, the world thanks you for sharing Nelson Mandela with us," Obama said, before going on to compare Mandela to Mahatma Gandhi, Martin Luther King and Abraham Lincoln.
He dismissed the notion of Mandela as a saint, saying instead that South Africa's first black president was a man who could admit to his flaws, and who showed deep humility.
"It was precisely because he could admit to imperfection, because he was so full of good humour, even mischief, despite the heavy burdens that he carried, that we loved him so.
"He was not a bust made of marble, he was a man of flesh and blood, a son and a husband, a father and a friend, and that's why we learnt so much from him."
Obama traced Mandela's life from his humble beginnings in rural Qunu, where he will be buried on Sunday, to his treason trial and finally to his years as South Africa's first democratic president and revered statesman.
"He turned his trial into an indictment of apartheid," he said.
"It is hard to eulogise any man... how much harder to do so for a giant of history, who moved a nation towards justice."
Obama's 20-minute speech drew cheers from South Africans, who packed into Soweto's FNB Stadium, where Mandela made his last public appearance three-and-a-half years before his death on Thursday, and a standing ovation from foreign dignitaries.
Foreign news agencies reported that Obama shook the hand of Cuban leader Raul Castro despite decades of hostility between their nations, and quoted Mandela's long-time personal assistant Zelda la Grange as saying Mandela would have hoped to unite foes as they bade him farewell.
Several nations -- including the US, Britain and France -- sent presidents past and present, Europe's royal houses dispatched representatives and Charlize Theron and U2 frontman Bono were among the celebrities who came to pay their respects.
Ordinary South Africans gathered at the gates of the stadium from dawn, and once inside danced and sang under a sea of umbrellas in celebration of Mandela, a scene that has played out in streets and squares since Mandela's death.
The government's fears that the 94,000 capacity stadium would be too small proved unfounded, and large sections remained unfilled.
After Obama, the leaders of Brazil, China, India, Namibia and Cuba paid tribute to Mandela, but some appeared to have come mainly to hear the US president and began filing out of stadium as rain continued to fall.
In her tribute, delivered in Portuguese, Brazilian President Dilma Rousseff said: "We must pay homage to this unmatched example of humanism," and she expressed her condolences to Mandela's Mozambican widow Graca Machel.
The memorial was shown on giant screens across the country. One of those who watched in Cape Town's Grand Parade, Ryan Roberts, simply commented: "I think Obama really nailed it."
It was the centrepiece of 10 days of national mourning for Mandela, who will lie in state at the Union Buildings in Pretoria from Wednesday to Friday. He will be buried at Qunu, in the Eastern Cape, where Mandela grew up.
There was a disappointment in Qunu, when many turned out to watch the broadcast on an open field only to find it had been cancelled.
"We are disappointed. We are very disappointed," 16-year-old Zikona Qukula said after rain disrupted arrangements for the screening.
"It was our last chance to see Tata, to see his pictures."