* Defence Ministry says ceasefire now in force
* At least 18 people killed over four days of fighting
* Conflict tested government's ability to impose order (Updates with more quotes, colour)
By Taha Zargoun
ZUWARA, Libya, April 5 (Reuters) - Rival militias whose clashes in western Libya have killed at least 18 people stopped fighting on Thursday, after the government sent in troops to impose a ceasefire, an army official said.
Reuters reporters in the town of Zuwara said there was no sign of fighting - in marked contrast to the day before when mortars and rockets were kicking up plumes of smoke, and the town hospital was over-flowing with the wounded.
The flare-up in violence tested the ability of Libya's National Transitional Council (NTC), in charge since a revolt ousted Muammar Gaddafi last year, to impose its authority on the fractious and volatile country.
Amara Ramadan, a Defence Ministry official, said a contingent from the national army had now moved in, four days after the fighting broke out, to keep the warring sides apart.
"We have been here since last night. We are at the frontline to separate the two sides and since last night there has been a ceasefire," he told Reuters in Zuwara.
"We have specific orders to use force in case one side does not respect the ceasefire," he said. "Until now it has been okay."
The fighting, which broke out at the weekend, was between militias in Zuwara, on the Mediterranean coast about 120 km (75 miles) west of the capital, and rival fighters in the nearby settlements of Al-Jumail and Regdalin.
Officials were using the break in hostilities on Thursday to exchange the bodies of people killed in the fighting so they could be buried in their own communities.
However, there were still signs of tension. Near the point where, a day earlier, Zuwara fighters clashed with militias from Regdalin, Defence Ministry troops had set up checkpoints and were preventing anyone with weapons passing through.
From the last checkpoint inside Zuwara-controlled territory, fighters from Regdalin could be seen about 500 metres away, driving up and down and trying to size up their opponents.
The violence has its roots in last year's rebellion against Gaddafi, which in the area around Zuwara, as in many other parts of the country, set one neighbour against another.
Zuwara's population, made up largely of members of the Berber ethnic group, opposed Gaddafi during the revolt. Their neighbours in the nearby settlements are mainly Arabs who had been loyal to Gaddafi.
That created mistrust and resentment which ignited at the weekend when, according to one account, a group of men from Zuwara out hunting for game shot dead a man from Al-Jumail by mistake. The hunters were briefly detained and, say people in Zuwara, mistreated, setting off the violence.
Subhe Juma, a spokesman for the Zuwara military council, said the town's leaders decided to stop fighting at a two-hour meeting on Wednesday. "We decided on the ceasefire and we will observe it," he said.
The head of the Regdalin local council told Reuters preparations were under way to exchange prisoners and that peace talks between the two sides were planned for Saturday in the capital, Tripoli.
"The army is here now," said the council chief, Ali Abd Al-Samad. "Things are quiet today."
In another confrontation that has underlined Libya's fragility, about 150 people were killed in clashes last week between rival tribes in the southern city of Sabha. (Additional reporting by Ali Shuaib in Tripoli; Writing by Christian Lowe; Editing by Alison Williams)