Editor’s Note — An earlier version of this story incorrectly said that President Barack Obama, on his way to the rostrum to speak at the memorial for Nelson Mandela on Tuesday, shook the hand of President Robert Mugabe of Zimbabwe.
Briefly laying aside differences hardened over decades, President Barack Obama on Tuesday shook the hand of the president of Cuba at the memorial service for Nelson Mandela.
The handshake appeared to be the first between American and Cuban presidents since 2000, when Bill Clinton and Fidel Castro greeted each other at a United Nations luncheon in New York, and only the second since 1959, when Castro took power.
It was Fidel Castro’s brother, Raul, named president of Cuba in 2008, who shook Obama’s hand on Tuesday.
Moments later, in a eulogy for Mandela, Obama offered criticism of governments that embrace Mandela’s legacy of racial reconciliation but “passionately resist even modest reforms” to fight poverty and inequality, and that imprison people for their political beliefs.
“There are too many who claim solidarity with Madiba’s struggle for freedom but do not tolerate dissent from their own people,” Obama said, referring to Mandela by his clan name.
On his way to the rostrum, Obama also hugged Dilma Rousseff, the president of Brazil, who has stridently opposed spying by the National Security Agency and criticized the U.S. government.
A White House official said that the Castro handshake “wasn’t a pre-planned encounter,” and that the White House appreciates that people from all over the world were there for the ceremony.
“As the president said, we urge leaders to honor Mandela’s struggle for freedom by upholding the basic human rights of their people,” the official said.
Texas Sen. Ted Cruz, the only senator to attend Mandela's service, walked out when Castro began to speak, his spokesman said.
"Sen. Cruz very much hopes that Castro learns the lessons of Nelson Mandela. For decades, Castro has wrongly imprisoned and tortured countless innocents," said Sean Rushton, a spokesman for Cruz, who is of Cuban descent and has said his father escaped from jail under the Castro regime.
"Just as Mandela was released after 27 years in prison, Castro should finally release his political prisoners; he should hold free elections, and once and for all set the Cuban people free."
In Havana, ordinary Cubans who heard about the handshake were wondering what to read into it.
"I believe it was a beautiful gesture and I hope that after this gesture, the relations between the two countries get better," said Aida Perez, a finance specialist.
But Rosa Martinez, a translator, chalked it up to protocol.
"For me, this was just the encounter in between two civilized persons who acted in a civilized way," she said.
Former President Jimmy Carter, who was also in Johannesburg for the Mandela service, shook hands with Fidel Castro on a visit to Cuba in 2002, long after Carter’s presidency. That trip was the first by a sitting or former American president to Cuba since Fidel Castro took power in 1959.
Obama stirred controversy with a handshake in the past. In 2009, the president shook hands with the late Venezuelan president Hugo Chavez — who called the United States “the biggest menace to our planet,” among other criticism — at the Summit of the Americas.
Stacey Klein, Kasie Hunt and Orlando Matos of NBC News contributed to this report.