CAIRO, Egypt -- The United Nations envoy to Libya urged the country's rival militias to cease fire and work on a political settlement, as the country's isolated parliament passed an anti-terrorism law aimed at battling warring militias that are taking hold of the country's biggest cities.

Bernardino Leon made his remarks during a Monday visit to the eastern city of Tobruk, the seat of the elected parliament. It is convening there because Islamist-allied militias have cemented their control Libya's capital, Tripoli, and second city of Benghazi, after defeating rivals in battles that forced thousands to flee.

Leon told reporters after holding talks with lawmakers that the parliament is the "legitimate representative of the Libyan people." Islamist-allied militias contest this point, having formed their own government and revived an outgoing parliament to take over legislative and executive authorities.

The clashes between militias have been the worst bout of violence Libya has witnessed since the downfall of dictator Moammar Gadhafi in 2011.

Thee elected Libyan parliament issued a 30-article law that criminalizes groups that use force to "terrorize people" and destabilize the country, prescribing sanctions that include the death penalty. The law passed with some 90 members out of 170 who attended the session on Tuesday.

The Libyan parliament is virtually powerless. It reappointed Abdullah al-Thinni as a prime minister but he has yet to form a government and present for a vote of confidence before parliament. In addition to the capital and Benghazi, it also has no control over the city of Misrata.

Lawmaker Tarek Groushi said that the law passed with a majority of votes -- 97 lawmakers out of 170 who attended Tuesday's sessions. He acknowledged that the parliament only controls half the country but said it has won international recognition.

"Foreign news agencies, UN envoy and British diplomats are streaming to Tobruk. The whole world recognizes us," he said.