(Adds seven dead, government statement)
By Feras Bosalum and Ulf Laessing
TRIPOLI, July 13 (Reuters) - Heavy fighting broke out between rival militias vying for control of Libya's main airport on Sunday, killing at least seven people and forcing a halt of all flights in the worst fighting in the capital for six months.
Explosions and anti-aircraft gunfire were heard from early morning on the airport road and other parts of Tripoli until the situation seemed to calm down in the late afternoon.
Residents said that militiamen from the northwestern region of Zintan who had controlled the airport came under fire, and local TV footage suggested that the attacking rebels were from the western city of Misrata.
The fighting is part of growing turmoil in the North African oil producer, where the government is unable to control battle-hardened militias that helped to overthrow Muammar Gaddafi in 2011 but continue to defy state authority.
Many Libyans are weary of militias whose members theoretically work for the government but who in reality appear to do as they please -- fighting each other or seizing oilfields and ministries as they press their own financial and political demands on authorities.
Zintan forces, which have controlled the airport since Gaddafi's ousting, and Misratis had been put on the state payroll in an unsuccessful attempt by the government to secure their cooperation and try to bolster the rule of law.
Seven people were killed and 36 wounded in the latest clashes, the Health Ministry said.
Comments on pro-Misrata websites suggested that the force was freeing the airport from Zintani control to hand it over to authorities.
The central government denounced the attackers as illegal. "The operation is led by civil leaders belonging to brigades and troops ... moving without orders and legal cover," the government of Prime Minister Abdulllah al-Thinni said in a statement.
Local news channel al-Nabaa showed men in military vehicles with Misrata insignia opening fire with heavy weapons.
Heavy smoke could be seen rising above the airport as an official said: "All domestic and international flights have been halted."
Nabaa TV showed a Libyan Airlines plane and a transport aircraft engulfed in smoke while vehicles fired anti-aircraft volleys and fighters took up positions next to a field of sheep.
Social media websites said that several rockets had hit the airport perimeter. Photographs on Facebook showed thick smoke at what was said to be the parking lot in front of the terminal. Families were trapped inside the building, local websites said.
The fighting was the worst in the capital since more than 40 people were killed in clashes between militias and armed residents in November.
Tripoli has seen a spike in kidnappings but has been mostly spared the kind of violence that has rocked the eastern city of Benghazi, where clashes between Islamists and forces loyal to a renegade general occur almost daily.
The violence comes as the country awaits the results of the June 25 parliamentary elections. Officials and Libya's partners had hoped the vote would give a push to state building and ease political tensions.
The OPEC member is divided between rival militias from urban communities and tribes, as well as Islamist and more moderate forces. Oil production has fallen to a fraction of the 1.4 million barrels a day that Libya produced before July 2013 when a wave of protests erupted at oilfields and ports.
The country's oil output is currently 470,000 bpd, a spokesman for state-run National Oil Corp said on Sunday.
The loss of oil revenues has sparked a budget crisis as Libya depends on energy exports. (Additional reporting by Ahmed Elumami in Benghazi; Editing by Lynne O'Donnell and Jane Merriman)