TRIPOLI, Nov 14 (Reuters) - Libya's first elected government was sworn in under tight security on Wednesday with the task of establishing democracy and reining in rival militias who helped overthrow Muammar Gaddafi last year.

In a national congress hall built by Gaddafi shortly before his fall, cabinet ministers swore an oath to protect the North African state, a major oil producer.

The national assembly approved Prime Minister Ali Zeidan's proposed government on Oct. 31 but the list set off violent protests outside congress.

A former diplomat who defected in the 1980s to become an outspoken Gaddafi critic, Zeidan will govern the country while the congress, elected in July, passes laws and helps draft a new constitution to be put to a national referendum next year.

Congress elected Zeidan prime minister last month after his predecessor lost a confidence vote over his choice of ministers.

On Wednesday, eight of the 27 ministers nominated by Zeidan were not present at the swearing in ceremony after some members of congress queried their credentials.

"This government will be strong, firm, strict and will do things with strength with the support of the national congress and the people of our country so we can achieve the ambitions and goals of the revolution," Zeidan said.

Outgoing Prime Minister Abdurrahim El-Keib handed over a gold-coloured replica of Libya to Zeidan. Cries of "God is greatest" filled the room as the ministers prepared to take the oath while a video showing stages of last year's uprising against Gaddafi was played.

The government has inherited a huge challenge in restoring order in a country ruled by Gaddafi for 42 years and riven with clan, sectarian and regional divisions.

SECURITY CHALLENGES

Earlier this month, rival militias - which gained power during the civil war - fired guns and rocket-propelled grenades at each other in Tripoli in one of the worst breakdowns in security in the capital since Gaddafi's fall.

Outgoing Interior Minister Fawzi Abdel A'al came under heavy criticism for mishandling security services and failing to integrate ex-rebel fighters into the official police force.

His suggested replacement, Ashour Shuail, was vetoed by an integrity commission for being too close to the Gaddafi government. Former fighters had descended on Tripoli last week to meet Zeidan and voice their dissatisfaction with his choice.

Shuail has appealed against the decision. A deputy minister will run the ministry meanwhile.

"The integrity commission itself needs an integrity commission," Shuail told Reuters. "The commission has become greater than the national congress and the government."

On Wednesday, the army cordoned off the congress headquarters, standing guard with pick-up trucks mounted with anti-aircraft weapons. Sniffer dogs were deployed.

"I swear to God that I will fulfil my duties with all dedication to be loyal to the goals of the February 17 Revolution and to respect the constitution and its rules and its articles and to care for the needs of Libyans and to protect Libya and the unity of its lands," each minister said.

Ministers in charge of electricity, higher education and relations with congress were also rejected by the integrity commission. A decision on four other nominees - foreign affairs, agriculture, social affairs and religious affairs - is pending.

"The country cannot suffer delays any more so we needed to swear in this government and hand it power," congress member Mohamed al-Hudeiri said.

"Pending a decision by the commission, these portfolios will be handled by the deputy ministers." (Additional reporting By Ghaith Shennib and Hadeel Al-Shalchi; Writing By Hadeel Al-Shalchi; Editing by Janet Lawrence)

We welcome comments that advance the story through relevant opinion, anecdotes, links and data. If you see a comment that you believe is irrelevant or inappropriate, you can flag it to our editors by using the report abuse links. Views expressed in the comments do not represent those of the Thomson Reuters Foundation. For more information see our Acceptable Use Policy.