JOHANNESBURG -- Amid cheers and song for the prisoner who became peacemaker, President Barack Obama energized tens of thousands of spectators at a soccer stadium and nearly 100 visiting heads of state Tuesday with a plea for the world to emulate Nelson Mandela, "the last great liberator of the 20th century."
Mr. Obama's eulogy was the rhetorical highlight of a memorial service in which South Africans celebrated Mr. Mandela's life with singing and dancing, often during dignitaries' speeches. They also booed their own president and were chided by a top government official who said: "Let's not embarrass ourselves."
Lashing rain lent a freewheeling aspect to the memorial, with people taking shelter in the stadium's wide hallways, where they sang anti-apartheid anthems from the 1970s and 1980s. Foul weather kept many away, and the 95,000-capacity stadium was only two-thirds full.
Mr. Obama implored people to embrace Mr. Mandela's universal message of peace and justice, comparing the South African leader to Mahatma Gandhi, Martin Luther King Jr. and Abraham Lincoln. Mr. Mandela spent 27 years in prison under a racist regime, and promoted forgiveness and reconciliation when he was finally freed.
"We will never see the likes of Nelson Mandela again," Mr. Obama said. "But let me say to the young people of Africa, and young people around the world -- you can make his life's work your own."
He hailed Mr. Mandela, who died Thursday at 95, as the unlikely leader of a movement that gave "potent voice to the claims of the oppressed and the moral necessity of racial justice."
"Born during World War I, far from the corridors of power, a boy raised herding cattle and tutored by the elders of his Thembu tribe, Madiba would emerge as the last great liberator of the 20th century," Mr. Obama said, referring to Mr. Mandela by his clan name.
Mr. Obama, who like Mr. Mandela became the first black president of his country, said he was inspired by Mr. Mandela as a student. The speech was greeted with thunderous applause, and many heads of state and other foreign dignitaries gave a standing ovation.
Mr. Obama pointed out that "around the world today, men and women are still imprisoned for their political beliefs, and are still persecuted for what they look like, or how they worship, or who they love."
Among the heads of state and government were some from countries such as Cuba that don't hold fully democratic elections. On the way to the podium, Mr. Obama shook hands with Cuban President Raul Castro, underscoring a recent warming of relations between their countries.
Other attending leaders criticized for their human rights records were Zimbabwe's Robert Mugabe, Equatorial Guinea's Teodoro Obiang Nguema and Gambia's Yahya Jammeh.
In contrast to the wild applause given to Mr. Obama, South African President Jacob Zuma was booed. Many South Africans are unhappy with Mr. Zuma because of state corruption scandals, though his ruling African National Congress, once led by Mr. Mandela, remains the front-runner ahead of elections next year.
Mr. Mandela's record after he was elected in the first all-race elections in 1994 has faced some criticism, most of it indirect because he is such a revered figure. He did not push for major restructuring of the economy, fearing that it could alienate whites who still control most of South African industry. Today, the country struggles with economic inequality, though Mr. Mandela's moral stature sets him far apart from his successors.
"Mandela was a very humble man, and he gave himself to the world. He sacrificed time with his family for us and for me. It is a privilege to be here, it is a humbling experience," said Dipolelo Moshe, 35, who works for a marketing company. She had a South African flag draped over her shoulders and carried a big photo of Mr. Mandela as she stood in line at the stadium.
Rohan Laird, 54, the CEO of a health insurance company, said he grew up during white rule in a "privileged position" as a white South African, and that Mr. Mandela helped whites work through a burden of guilt. "His reconciliation allowed whites to be released themselves," he said. "I honestly don't think the world will see another leader like Nelson Mandela."
A dazzling mix of royalty, statesmen and celebrities was in attendance.
Thabo Mbeki, who succeeded Mr. Mandela as president, got a rousing cheer as he entered the stands. French President Francois Hollande and his predecessor and rival, Nicolas Sarkozy, arrived together.
U.N. Secretary-General Ban Ki-moon waved and bowed to spectators as he called Mr. Mandela "one of our greatest teachers." Mr. Ban added: "He taught by example. He sacrificed so much ... for freedom and equality, for democracy and justice."
Mr. Mandela's widow, Graca Machel, and his former wife, Winnie Madikizela-Mandela, gave each other a long hug before the ceremonies began.
Actress Charlize Theron, model Naomi Campbell and singer Bono were among the celebrities paying final tribute.
Symbolically, Tuesday was the 20th anniversary of the day when Mr. Mandela and South Africa's last apartheid-era president, F.W. de Klerk, received the Nobel Peace Prize. Mr. de Klerk, a political rival who became friends with Mr. Mandela, was also in the stadium.
The rain was seen as a blessing among many of South Africa's majority black population. "Only great, great people are memorialized with it," said Harry Tshabalala, a driver for the Justice Ministry. "Rain is life. This is perfect weather for us on this occasion."
People blew on vuvuzelas, the plastic horn widely used during the 2010 World Cup soccer tournament in South Africa, and sang songs from the era of the anti-apartheid struggle decades earlier. "It is a moment of sadness celebrated by song and dance, which is what we South Africans do," said Xolisa Madywabe, CEO of a South African investment firm.
After Tuesday's memorial, Mr. Mandela's body will lie in state for three days at the Union Buildings in Pretoria, once the seat of white power, before burial Sunday in his rural childhood village of Qunu in Eastern Cape Province.