Barack Obama celebrated the life of Nelson Mandela with his own gesture of reconciliation at Tuesday's memorial ceremony in Soweto: a historic handshake with Cuban leader Raúl Castro.

It was the first such greeting in public involving a president of the United States since the Cuban revolution, although Bill Clinton shook hands in private with Raul's brother Fidel during a closed-door United Nations lunch in 2000.

Though initially unclear whether Obama and Raúl Castro's meeting was orchestrated or happened by chance, the symbolism of the moment helped set the mood for the unprecedented gathering of world leaders.

Obama also shook hands with Brazilian president Dilma Rousseff, who cancelled a recent trip to the US amid anger over revelations that the National Security Agency eavesdropped on her phone calls.

The US president appeared to address parts of his 15-minute eulogy to his fellow world leaders, calling on them to complete Mandela's peacemaking work. “The struggles that follow the victory of formal equality and universal franchise may not be as filled with drama and moral clarity as those that came before, but they are no less important,” he said.

President Barack Obama speaks to crowds attending the memorial service for former South African president Nelson Mandela. Photograph: Evan Vucci/AP Photograph: Evan Vucci/AP

“Around the world today, men and women are still imprisoned for their political beliefs; and are still persecuted for what they look like, or how they worship, or who they love.”

The controversial handshake with Castro is likely to dominate headlines back home in the US, where many conservatives fear the White House is preparing a broader rapprochement with communist leaders in Havana, but Obama's surprisingly political speech also included veiled criticism of dictatorships that neglect human rights and conservatives who ignore inequality.

“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.

“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. And there are too many of us who stand on the sidelines, comfortable in complacency or cynicism when our voices must be heard.”

Obama also elaborated on brief remarks he gave on the day of Mandela's death that described his own inspiration from the liberation struggle in South Africa.

“Over 30 years ago, while still a student, I learned of Mandela and the struggles in this beautiful land,” said Obama. “It stirred something in me. It woke me up to my responsibilities – to others, and to myself – and set me on an improbable journey that finds me here today. And while I will always fall short of Madiba’s example, he makes me want to be a better man.”

Obama's eulogy to the rain-lashed Johannesburg stadium was at times nearly drowned out by cheering and delayed by heavy traffic, but the president, accompanied by his wife and presidents George W Bush and Bill Clinton, used it to point out South Africa's historic parallels with the US.

“We know that like South Africa, the United States had to overcome centuries of racial subjugation,“ he said. “As was true here, it took the sacrifice of countless people – known and unknown – to see the dawn of a new day. Michelle and I are the beneficiaries of that struggle. But in America and South Africa, and countries around the globe, we cannot allow our progress to cloud the fact that our work is not done.”

A man holds a placard with an image of Nelson Mandela at the FNB Stadium in Johannesburg Photograph: Siphiwe Sibeko/Reuters Photograph: Siphiwe Sibeko/Reuters

Obama's greeting with Castro drew a relatively muted response from prominent Cuban-Americans. Florida Republican senator Marco Rubio, a son of Cuban immigrants, told ABC News: "If he was going to shake his hand he should have asked him about those basic freedoms Mandela was associated with that are denied in Cuba."

In Miami, Ramon Saul Sanchez, leader of the Cuban exile group Movimiento Democracia (Democracy Movement), expressed doubt that the greeting was not orchestrated. "It's hard to believe that a president going to an event where so many diverse leaders will be present, including several dictators, wouldn't think ahead of time who he's going to meet and what he's going to do when he does," he said.

"In reality, it's something they knew would happen and Obama conducted himself as he would have in front of any democratically elected leader. That's what hurts here. It's sad and it chokes the conscience of the victims of the Castro regime to see Obama shake hands with a dictator, especially on World Human Rights Day."

Experts in Cuban-American policy, meanwhile, doubted that the handshake marked any significant shift or advance in relations between the countries. "It wasn't as if it was in some big international forum such as the UN," said Susan Kaufman Purcell, director of the Center for Hemispheric Policy at the University of Miami.

"It was great photo opportunity for Raúl but it doesn't signal any change in policy. It's something people might have anticipated."