Donald Payne (L) met Somalia's president and prime minister
A US congressman has had a narrow escape on a visit to Mogadishu after Somali insurgents fired mortars towards his plane as it was about to take off.
Airport officials told the BBC one mortar had landed near the airport as Donald Payne's plane was due to fly and five others after his plane departed.
Mr Payne had just met leaders of Somalia's government in the capital.
The al-Qaeda-linked Islamist militant group al-Shabaab claimed responsibility for the mortar attack.
"We carried out mortar attacks against the enemy of Allah who arrived to spread democracy in Somalia," a spokesman for the group named as Sheikh Husein Ali Fidow was quoted as saying by AFP news agency.
"This government is welcoming America, which is our prime enemy and we will never stop attacking them."
The BBC's Mohammed Olad Hassan in Mogadishu says Mr Payne had just left a half-hour news conference at the presidential palace in the capital when the attack happened, according to airport officials.
Abukar Hassan, a police officer at Mogadishu airport, told Reuters news agency: "One mortar landed at the airport when Payne's plane was due to fly and five others after he left and no-one was hurt."
Three people were wounded when one of the mortars hit a nearby neighbourhood, residents told Reuters.
Mr Payne earlier met President Sheikh Sharif Sheikh Ahmed and Prime Minister Omar Abdirashid Ali Sharmarke, among other Somali officials.
He had discussed ways that the international community might be able to help war-torn Somalia.
The New Jersey Democrat said it was his first visit to Somalia since the early 1990s, when the country last had a stable government.
During his brief stop in one of the world's most dangerous cities, Mr Payne was escorted by African Union (AU) soldiers, who are deployed in Somalia on a peacekeeping mission.
Radical Islamist guerrillas control swathes of Somalia
An AU official told AFP on condition of anonymity: "The plane of the congressman was leaving and the mortars started falling. There were no casualties, but the attack was aimed at the congressman. He flew out safely."
Mr Payne discussed with his hosts Sunday's hostage drama in the Indian Ocean, when US forces shot dead three Somali pirates who had been holding an American ship captain for five days.
They also discussed peace and reconciliation in Somalia and possible co-operation between Washington and Mogadishu, our correspondent says.
The Somali prime minister said: "We discussed the current situation of Somalia, including the latest piracy incident, the progress the Somali government has made so far and the need for co-operation between the two countries. Our meeting ended in mutual understanding."
At the news conference earlier, Mr Payne said he was sure the Obama administration would look favourably on the Somali government, inaugurated earlier this year after a UN-backed peace process.
"We realise that the government cannot do things overnight," said Mr Payne, 74, who is chairman of the House Foreign Affairs Committee's subcommittee on Africa.
"It's going to take patience and time for the government to be able to start to provide services to its people.
"But the government will have a responsibility of proving that it's in the process of benefiting people," the former head of the Congressional Black Caucus added.
Radical Islamist guerrillas who have sworn to topple the fragile transitional federal government control parts of Mogadishu and much of central and southern Somalia.
The former top US diplomat for Africa, Jendayi Frazer, became the first high-ranking American official to visit Somalia in more than a decade when she landed in Baidoa in 2007, but the security situation kept her from visiting Mogadishu.
US foreign policy on the Horn of Africa nation has been overshadowed by the killing of 18 US soldiers in Mogadishu in 1993.
Somalia, a country of about eight million people, has not had a functioning national government since warlords overthrew President Siad Barre in 1991 and then turned on each other.