The president spent nearly half an hour inside the Robben Island prison cell where Mandela spent 18 years as a political prisoner before he was released and elected South Africa's first black president.
After his family left, Obama remained alone inside the cell that now is a monument to Mandela, a man Obama says is a "personal hero."
Obama visited the island in 2006 when he was a U.S. senator. Sunday's tour was a first for his wife, Michelle, and daughters, Malia and Sasha.
Mandela has been hospitalized for three weeks with a recurring lung infection. The 94-year-old remains in critical condition.
The White House says Obama met privately with members of Mandela's family and spoke with the former president's wife on Saturday. In keeping with the family's wishes, Obama did not meet with Mandela in the hospital.
The president says he's eager to teach his family about Mandela's role in overcoming white racist rule, first as an activist and later as a president.
Before departing, the president and first lady signed the visitors log.
"On behalf of our family we're deeply humbled to stand where men of such courage faced down injustice and refused to yield. 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 president wrote.
The president is in South Africa as part of his weeklong trip to promote U.S. investment opportunities and democracy.
The Associated Press and ABC News contributed to this report.