* PM orders regular military to control armed groups
* Benghazi airport closed due to clashes
* Algeria sends special forces to evacuate envoys (Adds airport closed, updates death tolll)
By Ayman al-Warfalli and Ahmed Elumami
BENGHAZI, Libya, May 16 Libyan irregular forces backed by helicopters clashed with Islamist militias in Benghazi on Friday in fighting that left at least 19 people dead and posed a new test to the fragile government.
Members of the self-declared Libyan National Army, led by retired General Khalifa Haftar, shelled bases belonging to Ansar al-Sharia and another Islamist militant group in Benghazi, said Mohamed Al-Hejazi, a spokesman for Haftar's forces.
The violence prompted Libya's prime minister to order the regular military to control any armed groups - including Haftar's forces - in the eastern city, where militants often clash with the army, and assassinations and bombings are common.
Authorities closed the city's Benina airport in the evening because of the clashes.
Since the 2011 civil war that ousted Muammar Gaddafi after 42 years of one-man rule, Libya has been unable to impose authority over brigades of former rebels who refuse to disarm and have carved out regional fiefdoms.
Highlighting the instability, Algeria sent a team of special forces to evacuate its ambassador and embassy staff from Libya in a military plane after a militant threat to its embassy, officials and a security source said on Friday.
Benghazi, the cradle of the NATO-backed uprising against Gaddafi, in particular has struggled to curb violence and stem attacks blamed on Ansar al-Sharia, which often operates openly despite being designated a terrorist organisation by Washington.
Prime Minister Abdullah al-Thinni told reporters: "We have given orders ... to intercept any force trying to enter Benghazi because they don't have legitimacy from the state."
Haftar, a leading figure in the anti-Gaddafi revolt, in February stirred rumours of a coup by appearing in military uniform to call for a presidential committee to be formed to govern until new elections.
It was not clear how much support he commands, but it seems likely his forces are drawn from the country's nascent army, which is still in training. Tripoli's government said in February he had no authority and threatened legal action.
Hejazi dismissed the government's rejection on Friday of the legitimacy of Haftar's forces and said they were forcing militants from their bases into the city because the government had failed to help Benghazi.
"We're telling them we have the legitimacy from the civilians who suffer on a daily basis from the killings targeting the police and military," he said. "We are fighting militias who threaten stability."
The city was calmer in the evening after the clashes in the morning, when witnesses said at least one regular army helicopter had been used in the assaults on the Islamist bases.
At least 19 people were killed and almost 70 injured in the fighting, medical sources at local hospitals said.
Libya's government is fragile and the parliament almost paralysed by rivalries, with little progress to full democracy made since 2011. A planned new constitution is still unwritten and the country is on its third prime minister since March.
U.S. and European countries are helping build up the regular army but Libya's armed forces and government cannot control the brigades of ex-rebels and militants who once fought Gaddafi.
The North African nation's vital oil export industry has suffered badly and is often targeted by armed protesters seeking a greater share of oil wealth, federalist power for the regions or just better basic services.
Since last summer, armed protesters have repeatedly closed down ports and oilfields, bringing production down to around 200,000 barrels per day from the 1.4 million bpd that the OPEC member state produced before the protests erupted. (Additional reporting by Ahmed Elumami; Writing by Patrick Markey; Editing by Alison Williams)