TRIPOLI, Libya (AP) — Libya's newly formed national assembly elected former opposition leader Mohammed el-Megarif as the country's interim president on Friday, the latest move to establish a democratically based leadership after decades of rule by deposed dictator Moammar Gadhafi.

El-Megarif won 113 votes to defeat another opposition leader and human rights lawyer, Ali Zidan, who won 85 votes from the 200-member General National Congress, an assembly created in the first nationwide election since Gadhafi's ouster and killing last year. Both men had been diplomats who defected and fought Gadhafi's regime while living in exile since the 1980s.

"This is a historic moment and no one is a loser," said Hussein al-Ansari, an independent lawmaker speaking after the victor was announced. "The two are nationalist fighters who battled the regime."

El-Megarif, who authored a series of books on Gadhafi's repressive policies, lived as a wanted fugitive for years, and was the leader of the country's oldest armed opposition movement, the National Front for the Salvation of Libya. The movement made several attempts to end Gadhafi's 42-year rule, sometimes by plotting assassination attacks including a well- known and daring 1984 assault on Bab al-Aziziyah, the late dictator's fortified compound in Tripoli.

The regime cracked down on the group, executing and arresting many of its members. Many fled abroad where they worked as political activists. El-Megarif's movement organized the first Libyan opposition conference in London in 2005 and called for the overthrow of Gadhafi's regime at a time when other groups, including the Muslim Brotherhood, accepted Gadhafi's outreach to the opposition.

Upon his return to Libya after last year's armed revolution, he formed a new party, the National Front, which sees Islam as a broad guideline to the state's affairs, but does not mention the implementation of Islamic Sharia law. However since el-Megarif's old movement was founded by several Islamists, and ex-members of the Muslim Brotherhood, he is seen as close to Islamist parties.

El-Megarif will hold the office until a new constitution is in place sometime next year. He replaces Mustafa Abdul-Jalil, head of the outgoing transitional council, which was disbanded Wednesday when Abdul-Jalil handed power to the new assembly.

The body, which voted just after midnight, was elected in July in a turnout that exceeded 60 percent.

It will choose a prime minister within 30 days, then decide on a mechanism to select a 60-member panel tasked with writing a constitution. The assembly had been charged with forming the panel until July, when in a last minute move the outgoing transitional council declared that the panel will be elected directly by the people.

Lawmakers however have said that the assembly has the right to reverse the move.