A roadside bomb hidden under scrap metal killed two people and wounded 10 others in the Somali capital.
The United Nations' refugee agency said more than 3,500 people have fled the seaside city because of the escalation of violence in recent weeks.
Mogadishu has seen little peace since government troops backed by Ethiopian forces drove an Islamic movement out of the city in December. Roadside bombs, attacks on government installations, assassination attempts and gunbattles have became common, and civilians are caught in the crossfire.
A recent nighttime curfew aimed at stemming the violence has done little to help government troops assert control over the city.
In Thursday's attack, government soldiers patrolling the northern part of Mogadishu, known to be a stronghold of Islamic insurgents, were targeted with a roadside bomb, said Feysal Hussein Sheik, who was sitting in front of Kaah Hotel.
"We ran away (from the scene) fearing that we would be arrested as suspects," Sheik said. "A government soldier and a civilian bystander died on the spot and 10 others, all of them civilians, were rushed to hospitals," Mogadishu's Police Chief Col. Ali Said told the Associated Press by telephone.
Also on Thursday, the International Medical Corps said one of its staff and a driver were killed Wednesday in a shooting near the Somali town of El-Berde, about 402 kilometers (250 miles) northwest of Mogadishu.
The two men were shot dead by three unidentified gunmen as they returned from a medical clinic operated by IMC in El-Berde Wednesday evening.
"Initial reports indicate the attack appeared to be related to tensions between rival clans living in the area," IMC spokesman Tyler Marshall said in a statement.
The explosion follows a day when unidentified gunmen lobbed three hand grenades at a police truck patrolling the main market in the capital, missing the truck and killing two shoppers.
Hours later, former Defense Minister Barre Hirale was injured in an assassination attempt when his car was hit by a land mine. The minister for trade, Abdullahi Ahmed Afrah, said he survived an assassination attempt in Mogadishu on Tuesday when a roadside bomb hit his bodyguards' car, killing one of them and injuring three others.
The U.N. refugee agency said only 123,000 of the estimated 401,000 civilians who fled fighting between February and May have returned to the city.
"These people say they will not come back until Mogadishu is completely safe," UNHCR said in a statement on Thursday, adding that some of the civilians who recently returned to the capital are leaving again.
"Others leave their neighborhood to move to another part of the city because of persistent bomb explosions close to their homes, especially in the north of the city. They fear being caught in skirmishes," the U.N. statement said.
Somalia has been mired in chaos since 1991, when warlords overthrew dictator Mohamed Siad Barre and then turned against one another, defending clan fiefdoms. The government was formed in 2004 with the help of the United Nations, but has struggled to assert any real control.
At least 14 people have been killed in violence this week.