President Obama implored the thousands of people gathered in a stadium and millions watching around the world on Tuesday to continue Nelson Mandela's mission of erasing injustice and inequality.
In a speech that received thunderous applause and a standing ovation at FNB stadium in Johannesburg, Obama called on people to apply the lessons of Mandela, who emerged from 27 years in prison under a racist regime, embraced his enemies when he finally walked to freedom and ushered in a new era of forgiveness and reconciliation in South Africa.
"We, too, must act on behalf of justice. We, too, must act on behalf of peace," said Obama, who like Mandela became the first black president of his country. Obama said that when he was a student, Mandela "woke me up to my responsibilities -- to others, and to myself -- and set me on an improbable journey that finds me here today."
Addressing the memorial service for Mandela, who died Thursday at age 95, 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 nearly 100 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 Cuba and the U.S.
More than half a century after the U.S. cut off diplomatic relations with Cuba, such exchanges between American and Cuban leaders are exceedingly rare. U.S. officials often have gone to great lengths to avoid having presidents meet Cuban leaders, even in passing.
Making his way to the podium for his speech, Obama also greeted Brazilian President Dilma Rousseff with a kiss on the cheek. Rousseff and Obama have clashed over reports the National Security Agency monitored her communications, leading the Brazilian leader to shelve a state trip to the U.S. earlier this year in a show of anger.
The U.S. and Cuba have recently taken small steps toward political reconciliation, raising hopes that Washington and Havana could be on the verge of a breakthrough. But skeptics caution the two countries have shown subtle signs of thaw in the past, only to fall back into old recriminations.
In 2009, Obama made waves when he shook hands with the late Venezuelan president Hugo Chavez, a strident critic of the United States, at the Summit of the Americas.
In contrast to the wild applause given to Obama, South African President Jacob Zuma was booed when he first entered the crowded stadium, and again when he prepared to speak.
According to Reuters, Zuma had been hoping to get a boost from the national emotion brought on by Mandela's death.
Zuma's African National Congress (ANC) government is facing violent unrest and protests over poverty, crime and unemployment. However, the ANC is still expect to win the elections in April or May, Reuters reported.
Some in the crowd reportedly accompanied the boos for Zuma with a thumbs-down gesture and rotating hand movements, the sign for a substitution in a soccer match.
The rainy weather and public transportation problems kept many people away. The 95,000-capacity stadium was only two-thirds full.
Some of the dozens of trains reserved to ferry people to the stadium were delayed due to a power failure. A Metrorail services spokeswoman, Lilian Mofokeng, said more than 30,000 mourners were successfully transported by train.
A dazzling mix of royalty, statesmen and celebrities were also in attendance.
Thabo Mbeki, the former South African president who succeeded Mandela, got a rousing cheer as he entered the stands. French President Francois Hollande and his predecessor and rival, Nicolas Sarkozy, arrived together. United Nations Secretary-General Ban Ki-moon waved and bowed to spectators who sang praise for Mandela, seen by many South Africans as the father of the nation.
"I would not have the life I have today if it was not for him," said Matlhogonolo Mothoagae, a postgraduate marketing student who arrived hours before the stadium gates opened. "He was jailed so we could have our freedom."
Rohan Laird, the 54-year-old CEO of a health insurance company, said in the stadium that 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," Lair said. "I honestly don't think the world will see another leader like Nelson Mandela."
Workers were still welding at a VIP area as the first spectators arrived amid an enormous logistical challenge of organizing the memorial for Mandela, who died Dec. 5 in his Johannesburg home at the age of 95.
Mandela's widow, Graca Machel, and former wife Winnie Madikizela-Mandela were at the stadium, and gave each other a long hug before the ceremonies began. So were actress Charlize Theron, model Naomi Campbell and singer Bono.
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 for their efforts to bring peace to their country. De Klerk, a political rival who became friends with Mandela, was also in the stadium.
Mandela said in his Nobel acceptance speech at the time: "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 sounds of horns and cheering filled the stadium. The rain, seen as a blessing among South Africa's majority black population, enthused the crowd.
"In our culture the rain is a blessing," said Harry Tshabalala, a driver for the justice ministry. "Only great, great people are memorialized with it. 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 World Cup soccer tournament in 2010, and sang songs from the era of the anti-apartheid struggle decades ago.
"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.
The soccer venue was also the spot where Mandela made his last public appearance at the closing ceremony of the World Cup. After the memorial, his 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.
The Associated Press and Reuters contributed to this report.