US President Barack Obama led world tributes Tuesday to Nelson Mandela, hailing him as 'a giant of history' at a rain-soaked memorial attended by tens of thousands of South Africans united in proud, noisy celebration.

Obama was one of close to 100 world leaders at the event in Soweto's World Cup stadium, where songs of praise and revolution, many harking back to the apartheid era that Mandela helped condemn to history, echoed down from the dancing crowds in the stands.

"It is hard to eulogize any man ... how much harder to do so for a giant of history, who moved a nation towards justice," Obama said, after being introduced to wild cheers.

"He was not a bust made of marble, he was a man of flesh and blood," Obama said of the prisoner-turned-president whose life story earned uncommon universal respect.

The four-hour event began at midday (1000 GMT) with a stirring rendition of the national anthem, Nkosi Sikelel' iAfrika (God Bless Africa), led by a mass choir and picked up with enthusiasm by the rest of the stadium.

Some 80,000 had been expected, but the venue was two-thirds full as the ceremony got underway under a curtain of rain that had been falling since the early morning.

Despite the profound sense of national sorrow triggered by Mandela's death last Thursday, the mood was upbeat, with people determined to celebrate the memory of one of the 20th century's towering political figures.

Cold War thaw? Obama and Castro shake hands

"His long walk is over, he can finally rest," African National Congress (ANC) Vice President Cyril Ramaphosa said in an opening address.

On several occasions, Ramaphosa felt forced to admonish boisterous sections of the crowd for chanting during the speeches.

In his tribute, UN Secretary General Ban Ki-moon noted that Mandela had managed to unite people in death, much as he had in life.

"Look around this stage ... we see leaders representing many points of view ... all here, all united," he said.

Before taking to the stage, Obama shook hands with Raul Castro, leader of long-time Cold War rival Cuba.

The handshake was seen by millions watching the memorial being broadcast live around the world, and comes as Obama tries to make good on his vow to reach out even to the most implacable of US foes.

Crowds had begun gathering at the Soweto stadium before daybreak and, as the gates opened, they swarmed inside the venue where Mandela made his last major public appearance at the 2010 World Cup final.

Wrapped in the South African flag or yellow-green coloured shawls printed with the slogan "Mandela Forever," they danced and sang -- oblivious to the constant drizzle.

"He's God given, he's God taken. We will never stop to cherish him," said Shahim Ismail, who took a day off from the sports academy he runs in Johannesburg to attend the event.

"This is once in your life. This is history," said Noma Kova, 36. "I didn't want to watch this on TV."

Mandela's widow, Graca Machel, received a huge ovation as she took her seat on the main stage constructed at one end of the pitch.

News of Mandela's death at his home in Johannesburg resonated around the world, triggering a wave of loving admiration from political and religious leaders, some of whom agree on little else.

In a nod to Mandela's extraordinary global reach, popularity and influence, the Indian, Brazilian and Namibian presidents, as well as Castro and the vice president of China all delivered eulogies.

'Too many claim solidarity with Mandela' without acting upon it

In his tribute, Obama took a swipe at authoritarian leaders who spoke of embracing Mandela's legacy without acting upon it.

"There are too many leaders who claim solidarity with Madiba's struggle for freedom, but do not tolerate dissent from their own people," he said,

The memorial event was part of an extended state funeral that will culminate in Mandela's burial on Sunday in the rural village of Qunu where he spent his early childhood.

South African President Jacob Zuma, who was roundly booed by sections of the crowd in a reflection of growing public dissatisfaction with the current generation of ANC leaders, hailed Mandela as "fearless freedom fighter."

"In his honour, we commit ourselves to continue building a nation based on democratic values, of human dignity and democracy," Zuma said.

Although Mandela had been critically ill for months, the announcement of his death was a body blow for this recently reborn nation.

He had been out of public life for more than a decade, but South Africans looked to his unassailable moral authority as a comforting constant in a time of uncertain social and economic change.

Ahead of the burial in Qunu, Mandela's body will lie in state for three days from Wednesday in the amphitheatre of the Union Buildings in Pretoria where he was sworn in as president in 1994.

Each morning, his coffin will be borne through the streets of the capital in a funeral cortege.

British Prime Minister David Cameron, French President Francois Hollande and Afghan President Hamid Karzai were among the leaders attending the memorial ceremony.

"We were told it was appropriate to wear a black tie," Cameron said after arriving at the stadium in Soweto.

"But when you come and your hear this great noise and this great atmosphere of celebration, it is clear that people here in South Africa want to, yes, say goodbye to this great man, yes commemorate what he did, but also celebrate his life and celebrate his legacy," he said.

Singer-activist Bono and South African actress Charlize Theron were among the celebrity mourners.