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.
"It took a man like Madiba to free not just the
prisoner but the jailer," US President Barack Obama
said, to a standing ovation. He said Nelson Mandela
embodied the spirit of "uBuntu", which means "I am
because you are".
Thousands braved the unseasonably cold weather and
rain to pay their respects to the country's first black
president at the FNB stadium in Soweto. This is where
he addressed the nation on the day of his release in
The crowds were in high spirits but were asked to
"behave" after booing President Jacob Zuma a number
of times. But despite a difficult start, President Zuma
delivered his message, describing Madiba as "truly one
of a kind".
He said Mr Mandela was a kind man but had a sharp
tongue, especially when it came to something he believed
in. Mr Zuma will have been relieved to hear some cheering
at the end of the speech.
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."
Barack Obama was cheered as he acknowledged the crowd
Thousands attended the memorial service, but rain, transport arrangements and the fact that Tuesday was not a national holiday meant many seats in the stadium went unfilled
Ex-wife Winnie Madikizela-Mandela hugged Mr Mandela's widow Graca Machel
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."
That Jacob Zuma was booed at the Nelson Mandela
memorial is unfortunate. This was not an occasion to
take pot shots. But it shows that South Africa is a
robust democracy - such booing would not have been
tolerated in many other countries. People would have
been too afraid to voice their rage at the president.
Nevertheless, Mr Zuma ought to be worried - will it be
the death knell for his political career? He is due to lead
the ANC into elections next year. A faction is bound to
lobby for him to be ousted, in favour of Cyril
Ramaphosa, his deputy in the party.
Acting as master of ceremonies, Mr Ramaphosa
received a far better reception from the crowd. He was
next to Mr Mandela when he was released from prison in
1990, and was the chief architect of South Africa's
At the time, he was widely seen as Mr Mandela's heir but
was outmanoeuvred in the political chess game within the
ANC to choose the legend's successor.
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.
Mr Mandela made his final major public appearance at the stadium at the 2010 football World Cup
More than 100 current or former heads of state or government will attend the funeral or the national memorial
President Jacob Zuma suffered the indignity of some booing
Singer Bono and South African actress Charlize Theron attended the ceremony
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.