Tens of thousands of South Africans have joined dozens of world leaders for the national memorial service for former President Nelson Mandela.
The service was held in front of a vociferous crowd in the FNB stadium in Johannesburg.
US President Barack Obama said Mr Mandela was a "giant of history", describing him as the last great liberator of the 20th Century.
The former South African president died last Thursday, aged 95.
The country is observing a series of commemorations leading up to the funeral on Sunday.
'A mighty life'
The memorial service, which began at about 12:00 (10:00 GMT), lasted about four hours.
It was one of the biggest gatherings of international dignitaries in recent years, with more than 100 current or former heads of state or government attending.
There had been fears people would be turned away. But with heavy rain, security and transport issues, and the fact that Tuesday was not declared a national holiday, areas of the 95,000-capacity stadium remained empty.
Introducing the proceedings, the master of ceremonies, Cyril Ramaphosa, said that Mr Mandela's "long walk is over... and he can finally rest".
Current South African President Jacob Zuma made the keynote address but was booed in some parts of the ceremony.
He said Mr Mandela was "one of a kind... a fearless freedom fighter who refused to allow the brutality of the apartheid state to stand in way of the struggle for the liberation of his people".
Mr Zuma announced he was renaming the Union Buildings in Pretoria, where Mr Mandela will lie in state, as the Mandela Amphitheatre.
Earlier Mr Obama delivered his address, carried on the White House web site, to huge cheers. 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."
He said Nelson Mandela had taught the world the power of action and the power of ideas, and that it had taken a man like Mr Mandela to free not only the prisoner but also the jailer.
Mr Obama said: "We will never see the likes of Nelson Mandela again. While I will always fall short of Madiba (Mr Mandela's clan name), he makes me want to be a better man."
On his way to the podium, President Obama shook hands with Cuban President Raul Castro, an unprecedented gesture between the leaders of two nations that have been at loggerheads for more than half a century.
A White House official later said the two had not planned to meet.
"This wasn't a pre-planned encounter," the official said, quoted by AFP news agency.
"Above all else, today is about honouring Nelson Mandela, and that was the president's singular focus at the memorial service. We appreciate that people from all over the world are participating in this ceremony."
In his address, Mr Castro paid tribute to Mr Mandela as the "ultimate symbol of dignity and the revolutionary struggle".
Under his brother, Fidel, Cuba was a staunch critic of apartheid, and Mr Mandela had expressed gratitude for that support.
In his speech, UN Secretary General Ban Ki-moon said there was "sorrow for a mighty loss and celebration of a mighty life".
He said: "South Africa has lost a hero, it has lost a father... He was one of our greatest teachers. He taught by example. He sacrificed so much and was willing to give up all he had for freedom and democracy."
The first speaker, friend and fellow Robben Island inmate Andrew Mlangeni, said Mr Mandela had "created hope when there was none".
Many people stood in the rain waiting for several hours to get into the stadium, the BBC's Pumza Fihlani reports from the scene.
She says the crowds were in high spirits - singing and dancing, stomping their feet - and the stadium had the feel of a political rally.
Rather than seeing the rain as a dampener, many in South Africa have welcomed it.
Defence Minister Nosiviwe Mapisa-Nqakula said: "It's a blessing from the ancestors welcoming a son of the soil."
One of those attending, Shahida Rowe from Johannesburg, told the BBC: "The core of Mandela's life was humanity. That is why I am here today and the world is celebrating.
"Thanks to him, I was recognised as a human being."
Mr Mandela's widow, Graca Machel, arrived at the stadium to huge cheers as she was shown on the big screen.
There were cheers too of "Winnie! Winnie!" for ex-wife Winnie Madikizela-Mandela, who hugged and kissed Graca Machel.
Brazilian President Dilma Rousseff, Chinese Vice-President Li Yuanchao, President Hifikepunye Pohamba of Namibia and Indian President Pranab Mukherjee also made speeches.
The ceremony was closed by Nobel Peace Prize laureate Archbishop Desmond Tutu, who asked the crowd to rise to their feet for a final tribute.
The BBC's Mike Wooldridge in Johannesburg says the line-up of world leaders is a sign of how South Africa has seen its partners and place in the world since Nelson Mandela became president.
But, he adds, today is as personal as it is political - a recognition that there are lessons for the wider world in everything Nelson Mandela sought to achieve.
British Prime Minister David Cameron attended Tuesday's memorial, along with Deputy Prime Minister Nick Clegg, Labour leader Ed Miliband and former British Prime Ministers Gordon Brown, Tony Blair and John Major.
Three former US presidents, George W Bush, Bill Clinton and Jimmy Carter, were also there, as were Francois Hollande of France, Palestinian leader Mahmoud Abbas and Zimbabwe's President Robert Mugabe.
Other mourners in attendance were Oprah Winfrey, Bono, Sir Richard Branson and Peter Gabriel.
Mr Mandela's body will lie in state in Pretoria on the following three days.
The state funeral takes place on Sunday in his home village of Qunu in Eastern Cape province.