MPs reportedly punched each other and wrestled after results showed that Ali Mohamed Gedi had received 88 votes and his opponents 126 - short of the two-thirds majority needed to censure him.
The fighting led to armed police entering the transitional government's building in Baidoa, a city about 150 miles northwest of the capital Mogadishu, reports said.
"I thank you all and show my gratefulness to those who voted to keep the government," Gedi said on Sunday.
"I equally thank those who voted against me for exercising their diplomatic right peacefully."
The vote followed the resignation on Thursday of at least 18 cabinet ministers, who complained that the government has failed to restore peace since an Islamist militia seized control of Mogadishu and much of southern Somalia last month.
The ministers also alleged that the government had invited Ethiopian troops into the country.
The deployment of the Ethiopian troops has split the country. The United Nations, the US and Western countries have said that any interference by Somalia's neighbours - such as Ethiopia and Eritrea - could disrupt efforts to achieve lasting peace.
Last Thursday a cargo aircraft said to be loaded with weapons landed in Mogadishu from Eritrea, in violation of a UN arms embargo.
Meanwhile Sheikh Hassan Dahir Aweys, head of the Islamic Courts group's council, has ruled out attending possible peace talks in Sudan with the interim government until the departure of Ethiopian troops.
"As long as they are in our country we will not attend the talks," he told Reuters on Sunday.