WASHINGTON — Even in death, Nelson Mandela is bringing together unlikely bedfellows.

For President Obama, the trip to South Africa for the international icon’s memorial service has been a steady series of encounters that can test diplomatic protocol.

The memorial drew dozens of dignitaries and heads of state, including three former U.S. presidents, a bipartisan congressional delegation, and leaders from around the world. Each brought a tangle of tricky relationships and subtext that had to be, at least publicly, set aside to honor a man who championed the art of reconciliation.

PHOTOS: A public farewell to Nelson Mandela

Among those world leaders was Cuban President Raul Castro, who was seated in the same VIP section as Obama at the memorial service Tuesday at a soccer stadium in the Johannesburg township of Soweto. Obama shook the Cuban leader’s hand as he greeted his fellow heads of state, generating a photo that immediately ricocheted around the Internet. 

It was the first such contact between a U.S. and Cuban president in 13 years, a White House official said. Cuban President Fidel Castro approached President Clinton to shake his hand at a United Nations meeting in 2000.

Like officials did then, the Obama administration did not assign extra meaning to the face-to-face encounter Tuesday, although it comes as Obama is planning to revisit U.S. policies toward Cuba.

The president was solely focused on honoring Mandela, said a White House official, who asked not to be named discussing the president’s private interactions.

“We appreciate that people from all over the world are participating in this ceremony,” the official said. “As the president said, we urge leaders to honor Mandela's struggle for freedom by upholding the basic human rights of their people.”

PHOTOS: Nelson Mandela through the years

More recent diplomatic tension also swirled around Obama at the high-powered gathering. After delivering his remarks, Obama was followed at the podium by Brazilian President Dilma Rousseff, who recently postponed a trip to Washington over reports that the U.S. had spied on Brazilian leaders. Obama had tried to smooth over trouble with Rousseff at a meeting of world leaders in Russia in September, without success.

The history-making memorial service was a hot ticket for U.S. lawmakers and a chance for the White House to do a little congressional outreach. The delegation of lawmakers that traveled to South Africa included several members of the Congressional Black Caucus, as well as Illinois Republican Rep. Aaron Schock and Texas Republican Sen. Ted Cruz, the latter among Obama’s toughest critics in the Senate.

The journey also promised another opportunity for political reconciliation. Obama has a history of friction — both ancient (by Washington standards) and fresh — with others on the African sojourn. Obama flew to South Africa with his predecessor and onetime political foil President George W. Bush and his wife, Laura Bush.

Also on the long, overnight flight was former Secretary of State Hillary Rodham Clinton. Ex-presidents Clinton and Carter planned to travel separately. Former President George H.W. Bush has been in frail health and did not make the long trip.

The White House gave only a little insight into the conversations among the travelers. Spokesman Jay Carney told reporters that the presidents and their wives at times congregated in a conference room on Air Force One, sharing memories of Mandela.

“It's a unique experience, obviously,” said National Security Council spokesman Ben Rhodes.

ALSO:

Crowds mourn as Nelson Mandela's 'long walk is over'

Obama pays tribute to Nelson Mandela as a 'great soul'

Mixed feelings about Mandela in South African mining town

Twitter: @khennessey

kathleen.hennessey@latimes.com