* Lawmakers meet far from Tripoli, in eastern seaside town
* Britain follows other Western nations and pulls out diplomats
* Fighting still raging at Tripoli airport (Adds comments on rejection of new parliament)
By Patrick Markey and Aziz El Yaakoubi
TRIPOLI, Aug 4 (Reuters) - Libya's new parliament appealed for national unity at its first formal session on Monday as rival armed factions battled for dominance of a country struggling to hold itself together three years after the fall of Muammar Gaddafi.
Hours before parliament met in the eastern city of Tobruk, heavy artillery and rocket fire bombarded southern and western Tripoli, where Islamist-leaning Misrata brigades have fought for three weeks with rival militias allied with the town of Zintan.
Lawmakers gathered in a heavily guarded hotel in Tobruk because three weeks of fighting in Tripoli and Benghazi had made Libya's two main cities unsafe for the parliamentary session.
Western nations, which have mostly pulled their diplomats out of the North African country due to the fighting, hope that the new assembly can nudge the warring factions toward a ceasefire and negotiations to end a political deadlock.
Elected in June, the House of Representatives replaces the General National Congress (GNC) after a vote which, analysts said, eroded the political dominance that Islamist factions linked to the Muslim Brotherhood had had in the legislature.
In a sign of Libya's deepening polarization, the Islamist former GNC president and a group of current and ex-GNC lawmakers rejected the Tobruk session as unconstitutional, setting the stage for more political infighting.
"A swift transition from the GNC to the new parliament is vital because the country is in turmoil," Azzedine al-Awami, the former deputy GNC chief, said at the first session.
"We hope all Libyans stand together to put our country's best interests first."
Justice Minister Saleh al-Marghani, standing in for the prime minister, who was attending a summit of African and U.S. leaders in Washington urged lawmakers to form a unity government.
Out of 188 elected lawmakers, 158 were sworn in during the session in Tobruk. They then elected Aguila Saleh Iissa as the House's president. Saleh is seen as a jurist and had occupied many judicial positions during the time of Gaddafi.
The United States, Britain, France, Italy and Germany quickly issued a joint call for parties to accept a ceasefire and a dialogue supported by the United Nations, and to recognize the authority of the parliament's elected representatives.
U.S. Secretary of State John Kerry, meeting with Libyan Prime Minister Abdullah al-Thinni during the summit in Washington, said it was a "critical time" for Libya.
"Libya's challenges can really only be solved by Libyans themselves, but we are committed to stand by them as they engage in the difficult work of doing so," Kerry said.
He said the United States was committed to returning diplomats to its embassy in Tripoli "as soon as the security situation allows."
But, underscoring the divisions over the legitimacy of the new assembly, in Tripoli outgoing GNC President Nouri Abusahmain, an Islamist leader, rejected the Tobruk meeting because of the way it had been held and the location of the session.
It was not immediately clear how much support his statement would generate or its impact on armed factions allied with the Islamist political leadership. Most Islamist-leaning lawmakers and ex-GNC members had stayed away from Tobruk.
More than 200 people have been killed in the recent fighting in Tripoli and the eastern city of Benghazi. Clashes have closed off most international flights, damaged Tripoli's main airport and sent foreign diplomats and workers fleeing abroad.
The battle for the airport is part of a wider political struggle between two loose factions of ex-rebels and their political allies who once fought together against Gaddafi, but whose rivalries exploded over the spoils of postwar Libya.
On one side are the Zintan brigades - based in the city some 130 km (80 miles) southwest of Tripoli - with their anti-Islamist Qaaqaa and Al-Sawaiq fighters, including some ex-Gaddafi forces, and political allies who say they are a bulwark against Islamist extremists taking over Libya.
Against them are fighters loyal to the western port of Misrata who are allied with the Islamist Justice and Construction party, an arm of the Muslim Brotherhood, who say they are fighting to purge ex-Gaddafi elements.
OIL OUTPUT DROPS
In a worrying development for Libya's budget, the country's lifeline oil production has slipped to 450,000 barrels per day (bpd)from 500,000 bpd a week ago, the National Oil Corp said on Monday, without explaining why output had fallen.
Even the previous figure is well below the 1.4 million bpd Libya produced a year ago, before strikes and blockades cut output and exports from the OPEC state.
Britain was closing its embassy operations on Monday, one of the last foreign governments to pull out its diplomatic staff, following the evacuation of the United States and the United Nations after the fighting erupted in Tripoli.
A Royal Navy ship on Sunday evacuated more than 100 British citizens, Libyan families and some foreign nationals. Some diplomats crossed by road into neighboring Tunisia.
With its national army still in formation, Libya's fragile government has long struggled against the power of the militias, which have skirmished in parts of the capital since 2011.
Many of the militia brigades are on the government payroll, approved by competing factions in ministries and the parliament, but are often more loyal to commanders, political allies or regions than to the Libyan state.
The General National Congress was stormed numerous times by different militia brigades trying to pressure lawmakers on political decisions or to demand that it dissolve.
Most of Tripoli has stayed largely calm, with fighting mainly restricted to the de facto front lines in the south and parts of the west of the city. Fuel prices have soared on the black market as fighting has caused shortages.
In Benghazi, an alliance of Islamist fighters and ex-rebels have joined together to battle Libyan armed forces, seizing a special forces military base last week and pushing the army outside the city.
Those Islamists, from the Ansar al-Sharia group, are branded a terrorist organization by Washington and have been blamed for a 2012 attack on the U.S. mission in Benghazi in which the U.S. ambassador and three other Americans died. (Additional reporting by Ayman al-Warfalli in Tobruk, Ahmed Elumami in Benghazi and Heba al-Shibani in Tripoli; Writing by Patrick Markey; Editing by Robin Pomeroy and Jonathan Oatis)