(CNN) -- A surprise trip from Ugandan President Yoweri Kaguta Museveni to Somalia has made him the first head of state to visit the war-torn country in almost 20 years, according to the African Union Mission for Somalia.
Museveni met with dozens of Ugandan peacekeepers, including ordinary soldiers and top commanders, immediately after arriving at the main southern Halane base in Mogadishu on Sunday afternoon, a statement from the mission said.
"We should be happy that our country is taking the lead in helping solve the Somalia problem," Museveni told his troops, who were thrilled at the sight of their leader and welcomed him with songs and dance, said the statement.
"His visit will surely motivate us to work harder to support our Somali brothers," Pvt. Mukona Eliya told the mission.
Later in the day, Museveni held a private meeting with Somali leaders at a UN compound within the base, amid tight security. In attendance were President Sheikh Sharif Sheikh Ahmed, Prime Minister Mohamed Abdullahi and Speaker of Parliament Sharif Hassan Sheikh Aden.
Sunday's visit is Museveni's second to Mogadishu since 1992, the African Union Mission said.
"We see his visit as historic, and we warmly welcome him," Sheikh Sharif said in the statement.
The Ugandan president also visited the mission's main hospital, which is run by Ugandan peacekeepers and gives free treatment to Somali government forces.
On July 11, a series of bombs tore through an Ethiopian restaurant and a rugby center in the Ugandan capital of Kampala. Officials said the blasts, which killed 79 people, were probably set off by suicide bombers.
Four people were arrested and charged in connection with the attacks.
The militant group Al-Shabaab has claimed responsibility for the bombings.
Members of the group have said they were acting in retaliation for Uganda's contribution of troops for peacekeeping operations in Somalia, which has been at war for nearly two decades.