Police were expecting a crushing crowd at FNB stadium in Soweto and had set up overflow points with big screen TVs, but rainy weather and public transportation problems kept many away. The 95,000-capacity stadium was only two-thirds full.
The rain was seen as a blessing among many of South Africa's majority black population.
"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."
The service for Mandela, who died Thursday at age 95, was four hours of singing, dancing, hugging and laughing. At one point, the crowd had to be asked to tone it down so that the speakers could be heard.
U.S. President Barack Obama electrified the crowd, urging the tens of thousands to apply the lessons of Mandela and his universal message of peace and justice. His message was received with thunderous applause.
"We, too, must act on behalf of justice. We, too, must act on behalf of peace," said Mr. Obama, who like Mandela became the first black president of his country. He 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."
"To the people of South Africa, people of every race and walk of life, the world thanks you for sharing Nelson Mandela with us. His struggle was your struggle," Mr. Obama said. "His triumph was your triumph. Your dignity and hope found expression in his life, and your freedom, your democracy is his cherished legacy."
It was the largest gathering of world leaders ever. There were 91 current heads of state and 10 former heads of state, including Mr. Obama's predecessors George W. Bush, Bill Clinton and Jimmy Carter.
On the way to the podium, Mr. Obama shook hands with Cuban President Raul Castro, underscoring a recent warming of relations between Cuba and the U.S.
In contrast to the wild applause given to Mr. Obama, South African President Jacob Zuma was booed. Many South Africans are unhappy with Zuma because of state corruption scandals.
Three of Mandela's 18 grandchildren and 12 great-grandchildren also took the stage to honor their grandfather. Also in the crowd were actress Charlize Theron, model Naomi Campbell and singer Bono.
After the 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.
The Associated Press contributed to this report.