President Barack Obama is on his way back to the US after visiting Tanzania, the last leg of his Africa tour, which also included Senegal and South Africa.
Earlier he 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.
The president was joined for the ceremony by predecessor George W Bush.
Mr Bush was in Dar es Salaam for a conference on African women sponsored by the George W Bush Institute.
While he and Mr Obama attended the ceremony at the US embassy memorial, their wives took part in the African First Ladies Summit.
Tanzanian President Jakaya Kikwete walked Mr 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 honour saluted and marching bands played as the couple boarded the plane.
The US president 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 $7bn (£4.6bn) 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," he 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, Mr 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 modernise customs, move to single more efficient border crossings, reduce bottlenecks, reduce the roadblocks that stymie the flow of goods to market," he said.
Mr 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 by decriminalising homosexual acts.
The US president 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.