TRIPOLI (Reuters) - The United Nations is committed to helping Libya organize elections by the end of this year, encouraged by the rate at which Libyans have been registering to vote, a top U.N. official said on Wednesday.

The U.N. hopes elections can help stabilize Libya, which was thrown into turmoil after long-time leader Muammar Gaddafi was toppled in a NATO-backed uprising in 2011.

Holding elections is a major challenge in a country still split among military and political factions, and where rival governments have claimed authority since the result of a 2014 vote was disputed. Security in many parts of Libya is poor.

A new electoral law would likely have to be agreed and a referendum on a constitution held before national polls.

A U.N. effort launched in September aims to amend a December 2015 peace plan for Libya and pave the way for a vote, but has so far produced no deal on how to move toward one.

Jeffrey Feltman, U.N. Under-Secretary-General for Political Affairs, said the U.N. saw elections this year as a route to a “peaceful and inclusive end to the transition phase”.

“The goal is a Libyan goal: to end the transition phase with an inclusive peaceful process that produces a unified government that is a product of the will of the Libyan people,” Feltman told reporters in Tripoli after meeting Fayez Seraj, head of the internationally recognized government.

“I had the opportunity to talk to the prime minister about the commitment of the secretary-general, the hope of the United Nations, to see inclusive elections take place in 2018, and to pledge the support of the United Nations to support those elections.”

Feltman said the U.N. had been “very encouraged” by the apparent enthusiasm for elections, pointing to around half a million new voters who have signed up since voter registration was opened in early December.

“Public opinion poll after public opinion poll demonstrate the strong support of the majority of Libyans from all parts of the country to be able to participate in credible elections and to be able to participate in credible elections in this year,” he said.

Libya’s election commission says a total of 1,965,450 people are now registered to vote, out of a population of more than six million. Turnout in the 2014 election was just 630,000. The polls led to a battle for control of Tripoli, and to rival governments being set up in the capital and in eastern Libya.

The government in the east is aligned with powerful military commander Khalifa Haftar, a likely contender in any presidential poll.