President Obama and his family on Sunday visited South Africa’s Robben Island, the jail where anti-apartheid leader Nelson Mandela was imprisoned for 18 years.

The first family paid tribute to Mandela, who became South Africa’s first black president after his release, and others who were imprisoned on the island.

"On behalf of our family we're deeply humbled to stand where men of such courage faced down injustice and refused to yield,” the president and first lady wrote in the guest book, according to a White House pool report. “The world is grateful for the heroes of Robben Island, who remind us that no shackles or cells can match the strength of the human spirit.”

The visit came as the 94-year old Mandela remains hospitalized in critical condition as he battles a serious lung infection. On Saturday, the president met with Mandela’s family members.

In a statement Saturday Obama paid tribute to Mandela and the “profound impact that his legacy has had in building a free South Africa, and in inspiring people around the world - including me.”

The Obamas received a tour of the prison from anti-apartheid activist Ahmed Kathrada, who served 26 years in prison, including 18 on Robben Island.

The first family stopped by the jail cell where Mandela stayed on the island.

Later the president was heard telling his daughters how Indian independence leader Mahatma Gandhi also developed his ideas of non-violent political opposition in South Africa. 

“The idea of political nonviolence first took root here in South Africa because Mahatma Gandhi was a lawyer here in South Africa. Here is where he did his first political [activism],” the president said, according to the pool report. “When he went back to India the principles ultimately led to Indian independence, and what Gandhi did inspired Martin Luther King."

The visit came during Obama’s week long trip to Africa. On Saturday he held bilateral meetings with South African President Jacob Zuma and attended a state dinner in Pretoria.