DAKAR, Senegal — President Obama looked across the Atlantic Ocean as he stood in a stone doorway at Gorée Island, a symbolically important landmark that serves as a reminder of ships bound for America bearing African slaves in shackles.

America’s first black president spent about a half-hour inside the slave house on the edge of the water, walking quietly with his wife, Michelle Obama, a descendant of slaves, by his side.

Photographers briefly captured a reflective-looking president in the “door of no return.” Afterward, Mr. Obama was stoic, describing the visit only as a “very powerful moment” that helped him to “fully appreciate the magnitude of the slave trade,” which for so long defined the history of blacks in the United States.