Earlier Barack Obama laid a wreath for the victims of the 1998 US embassy bombing in the Tanzanian city of Dar es Salaam.
Eleven people were killed in the al-Qaeda attack, which coincided with a bombing in the Kenyan capital, Nairobi, which left hundreds dead.
President Barack Obama was joined for the ceremony by predecessor George W. Bush.
George W. Bush was in Dar es Salaam for a conference on African women sponsored by the George W. Bush Institute.
While the former president and Barack Obama attended the ceremony at the US embassy memorial, their wives took part in the African First Ladies Summit.
Tanzanian President Jakaya Kikwete walked Barack Obama and his wife down a red carpet to the Air Force One at the international airport in Dar es Salaam on Tuesday.
A guard of honor saluted and marching bands played as the couple boarded the plane.
President Barack Obama had arrived in Tanzania on Monday.
During his stay, he also visited a US-owned power plant, following his announcement over the weekend of a multi-billion-dollar electricity initiative.
The $7 billion five-year initiative is intended to double access to electricity in sub-Saharan Africa, in partnership with African countries and the private sector.
“We’re starting with countries that are making progress already with reforms in the energy sector – Tanzania, Ethiopia, Kenya, Nigeria, Ghana, Uganda, Mozambique and Liberia,” Barack Obama told a business leaders forum in Dar es Salaam.
“And with a focus on cleaner energy, we will initially add 10,000 megawatts of new electricity generation, which expands electricity to 20 million homes and businesses.”
At the same forum on Monday evening, Barack Obama launched a programme helping Africa’s eastern nations of Burundi, Kenya, Rwanda, Tanzania and Uganda trade both with each other and with the US.
“We’ll work with the countries involved to modernize customs, move to single more efficient border crossings, reduce bottlenecks, reduce the roadblocks that stymie the flow of goods to market,” he said.
Barack Obama’s second tour to sub-Saharan Africa since becoming president began in Senegal where he called on African governments to give gay people equal rights.
President Barack Obama excluded from his week-long itinerary Kenya, where his father was born, and Nigeria, Africa’s biggest oil producer which has been hit by an Islamist insurgency.
bGxYv0GcEyUThe US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…