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.
bGxYv0GcEyUImage source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…