Obama's eulogy was the rhetorical highlight of a memorial service in which South Africans celebrated 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.
Obama implored people to embrace Mandela's universal message of peace and justice, comparing the South African leader to Mahatma Gandhi, Martin Luther King Jr. and Abraham Lincoln. 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," 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 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," Obama said, referring to Mandela by his clan name.
Obama, who like Mandela became the first black president of his country, said he was inspired by Mandela as a student. The speech was greeted with thunderous applause, and many heads of state and other foreign dignitaries gave a standing ovation.
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 like Cuba that don't hold fully democratic elections. On the way to the podium, 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 Obama, South African President Jacob Zuma was booed. Many South Africans are unhappy with Zuma because of state corruption scandals, though his ruling African National Congress, once led by Mandela, remains the front-runner ahead of elections next year.
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 it could alienate whites who still control most of South African industry. Today, the country struggles with economic inequality, though 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 35-year-old Dipolelo Moshe, who works for a marketing company.
She had a South African flag draped over her shoulders and carried a big photo of Mandela as she stood in line at the stadium.
Rohan Laird, the 54-year-old CEO of a health insurance company, said he grew up during white rule in a "privileged position" as a white South African and that Mandela helped whites work through a burden of guilt.
"His reconciliation allowed whites to be released themselves," Laird 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 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 Mandela "one of our greatest teachers."
"He taught by example. He sacrificed so much ... for freedom and equality, for democracy and justice," Ban said.
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 Mandela and South Africa's last apartheid-era president, F.W. de Klerk, received the Nobel Peace Prize. De Klerk, a political rival who became friends with Mandela, was also in the stadium.
In his Nobel acceptance speech at the time, Mandela said: "We live with the hope that as she battles to remake herself, South Africa will be like a microcosm of the new world that is striving to be born."
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 that was 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, 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.