Hundreds of world leaders and delegates have gathered in Johannesburg, South Africa for Nelson Mandela's memorial service. Despite the animosity between some governments, their leaders were seen in the same room together, shaking hands in memory of the anti-apartheid hero's legacy of reconciliation.

United States President Barack Obama, who gave an inspiring eulogy in memory of his idol Mr Mandela, was seen shaking hands with Cuba's Raul Castro when he was on his way to the podium. Also in attendance were former U.S. presidents Jimmy Carter, Bill Clinton and George W. Bush.

Thousands of mourners flocked to Johannesburg's FNB Stadium to pay tribute to a great leader and champion of democracy. While some people in the memorial service reflected on the life of Mr Mandela, some world leaders took the opportunity to take a quick "selfie" with fellow leaders.

U.S. President Obama, British Prime Minister David Cameron and Danish Prime Minister Helle Thorning-Schmidt were photographed moving close together for a quick picture using a mobile phone while Mr Mandela's memorial service was going on. The "selfie" showing the three world leaders prompted criticism especially in social media for not keeping in tone with the service.

As the three world leaders smiled for the camera, Mr Obama's wife, and U.S. First Lady Michelle Obama was seen looking unimpressed.

Before the selfie was taken, Mr Obama delivered an emotional eulogy in honor of Nelson Mandela and called the former South African president a "giant of history". Mr Obama said Mr Mandela's victory was the victory of the people. He said he was inspired to join politics because of Mr Mandela.

The selfie image of the Mr Obama, Mr Cameron and Ms Thorning-Schmidt went viral on the Internet. Twitter users were quick to react and said it was inappropriate for world leaders to take selfies in a funeral especially in the memorial service of Mr Mandela, who died at the age of 95.

President Obama took a selfie at Nelson Mandela's memorial service http://t.co/uNTRqb3Zg4 pic.twitter.com/YhcfGjvtcW

— The Verge (@verge) December 10, 2013

The selfie received mixed reactions on Twitter:

@Inertia_Taghi @samhouston @verge dude nobody takes selfies at a memorial service, that's common sense — Koller Dominik (@NBH_Vash) December 10, 2013

@Daqqy @NBH_Vash @verge I personally don’t think funerals are all about being eternally sad and sulking. It’s about celebrating life

— Sam Houston (@samhouston) December 10, 2013

Mr Obama had arrived at FNB Stadium after an hour the memorial service began. The crowd cheered and gave him a prolonged applause when the big screen showed his image. This is a stark contrast to the crowd's reaction when South African president Jacob Zuma appeared on the screen. People's cheers turned to jeers whenever they see Mr Zuma onscreen.

In Mr Obama's speech, he said Mr Mandela taught not only the power of action but the importance of ideas, reasons and arguments. He spoke against the dictators of other countries like China and Zimbabwe who praise Mr Mandela after his death while repressing their own people.

Mr Obama ended his speech by saying the world might never see the likes of Nelson Mandela again. He addressed the young people of Africa and around the world to make their life's work like the anti-apartheid hero's life.