The UN Security Council has voted to authorise a regional force to bolster Somalia's weak government, which is under pressure from Islamist militias.
The African peacekeepers are likely to face opposition in Somalia
The US-led resolution, co-sponsored by Congo, Ghana and Tanzania, also urged the government to resume peace talks.
The agreement also called for the easing of a 1992 arms embargo to allow Somali government forces to re-arm.
The resolution supported an 8,000-strong mission from the seven nations of east African body, Igad.
The resolution, adopted unanimously by the 15-nation council, said Somalia's transitional government represented "the only route to achieving peace and stability" in the country, which has been without effective central government since 1991.
However, observers believe it will be a long time before any peacekeepers arrive and say the UN resolution may be primarily intended to show symbolic support for the government.
The peacekeepers are likely to face strong opposition from the Union of Islamic Courts (UIC), which seized the capital, Mogadishu, in June before taking control of much of the south and centre of the country.
The UIC say they are capable of restoring security to the country, so there is no need for foreign peacekeepers.
They see a peacekeeping force as cover for Ethiopian troops being sent to help the government, even though the resolution rules out sending troops from states that border Somalia, such as Ethiopia.
The UIC has declared "Holy War" on Ethiopia, which has twice fought wars with Somalia, over control of Ethiopia's large Somali-speaking region.
Ethiopia denies sending troops to help Somalia's government but admits to providing military trainers.
Outgoing US ambassador to the United Nations John Bolton said not intervening was not an option.
"The other option is that the instability we have seen in Somalia for over 15 years would spread to the region," he said.
"I think the choice of doing nothing is really not a choice at all."
The aim of the force would be to protect transitional institutions located in Baidoa, some 250km (155 miles) north-west of the capital.
Washington also fears the Islamists are offering shelter to al-Qaeda operatives, a charge they deny.
Experts worry a spiralling conflict could spill over into other countries in the Horn of Africa.
The fear in particular is that Ethiopia and Eritrea will come into conflict because they support opposite sides and might see in Somalia another battleground in which to continue the intermittent war over their own border dispute.
The Islamists have removed the check-points, at which gunmen used to extort money from commercial vehicles in Mogadishu.
In some areas, they have imposed strict Sharia law, such as public executions of murderers and floggings for drug dealers.
Some cinemas which show foreign films and football matches and radio stations which ban Western music have been closed but in other areas under UIC control, such activities have been allowed to continue.
They have also banned the popular stimulant, khat.