David Cameron has attempted to explain why he decided to lean in for a ‘selfie’ with Barack Obama and the Danish prime minister Helle Thorning-Schmidt during Nelson Mandela’s memorial service in Johannesberg yesterday.

Speaking to MPs today, he said: “When a member of the Kinnock family asked me for a photograph, I thought it was only polite to say yes.”

Thorning-Schmidt, the Social Democrat leader in Denmark, is married to former Labour leader Neil Kinnock’s son, Stephen Kinnock.

Download the new Independent Premium app Sharing the full story, not just the headlines

However, his comment may do little to offset the outrage sparked by the whimsical mobile photo, which many deemed ‘inappropriate’ given the nature of the occasion.

“What selfish morons take a 'selfie' at a memorial service? Oh yeah that's right, Barack Obama and David Cameron,” one Twitter user wrote.

“You have precisely zero class or decorum,” another message, directed at David Cameron, read.

And they weren’t the only ones who were less than impressed. Michelle Obama was captured looking stony-faced as her husband snapped away with the two leaders in the stands.

Mandela's Memorial: The Ultimate Who's Who

Earlier on, the President called the former South African leader a “giant of history” in a moving tribute, which was strangely delivered to a sparsely populated stadium that was only a third full.

The crowd – a mix of thousands of singing supporters and 90 world dignitaries – emitted a roar as Obama took his seat, in marked contrast to the boos that greeted scandal-plagued South African President Jacob Zuma.

In his speech, Obama compared Mandela to Mahatma Gandhi, Martin Luther King Jr and Abraham Lincoln, declaring that the legacy of the leader who defeated apartheid must not be wasted.

He chided leaders who were quick to claim solidarity with Mandela's struggle with oppression and injustice, but did not allow freedom in their own countries.

Daily coronavirus briefing No hype, just the advice and analysis you need Enter your email address Continue Continue Please enter an email address Email address is invalid Fill out this field Email address is invalid Email already exists. Log in to update your newsletter preferences Register with your social account or click here to log in I would like to receive morning headlines Monday - Friday plus breaking news alerts by email Update newsletter preferences

“There are too many of us who happily embrace Madiba's legacy of racial reconciliation, but passionately resist even modest reforms that would challenge chronic poverty and growing inequality,” he said.

“There are too many leaders who claim solidarity with Madiba's struggle for freedom, but do not tolerate dissent from their own people,” he said.

As well as Castro, Obama also shook hands with Brazilian president Dilma Rousseff, who has been stridently critical of National Security Agency spying.

Video: Obama selfie at Mandela memorial