Image copyright AFP Image caption Prime Minister Xanana Gusmao says he's confident of winning a majority

East Timor has voted in general elections seen as a key test in deciding whether UN peacekeepers leave by the end of the year.

The UN said that it would withdraw its troops if the parliamentary polls go smoothly following peaceful presidential elections in April.

But with 21 parties standing, forming a new government could prove difficult if there is no clear majority.

UN peacekeepers arrived in 2006 after widespread fighting and unrest.

East Timor gained independence in 2002 after three years of UN administration, which followed more than two decades of bloody guerrilla warfare during Indonesian rule.

But an outbreak of gang violence in 2006 prompted the UN Security Council to set up a new peacekeeping force, Unmit. The UN said poverty and unemployment had exacerbated the unrest.

As he voted in the capital, Dili, Prime Minister Xanana Gusmao said his centre-left National Congress for Timorese Reconstruction (CNRT) had done a "good job" and was hoping for backing from voters.

He said he was confident of winning a parliamentary majority.

The other major party contesting the elections is the left-wing Fretilin.

Its secretary-general, Mari Alkatiri, promised that if elected, he would strive to root out corruption.

The campaign was dominated by economic issues, with the two main parties focusing their promises on what to do with the country's $10.5bn (£6.8bn) oil fund.

While the country is considered one of Asia's poorest nations, vast offshore oil and gas fields in the Timor Sea hold much potential.

Two rounds of presidential elections were held in March and April, with former guerrilla leader Taur Matan Ruak elected to the largely ceremonial post.