TRIPOLI, Libya — Jubilant Libyans chose a new parliament Saturday in their first nationwide vote in decades, but violence and protests in the restive east underscored the challenges ahead as the oil-rich North African nation struggles to restore stability after the ouster of longtime dictator Moammar Gadhafi.
One person was killed and two wounded in a gunbattle between security forces and anti-election protesters in the eastern city of Ajdabiya, according to the head of the election commission. Nouri al-Abari said the polling center targeted by the protesters was later reopened and voting commenced normally.
The shooting followed a spate of attacks on polling centers in the eastern half of the country, which was the cradle of the revolution against Gadhafi but has become increasingly angry over the perceived domination of power by rivals in Tripoli.
The vote capped a chaotic transition that has exposed major fault lines ranging from the east-west divide to efforts by Islamists to assert power.
Lines formed outside polling centers more than an hour before they opened in the capital Tripoli, with policemen and soldiers standing guard and searching voters and election workers before they entered.
‘‘I have a strange but beautiful feeling today,’’ dentist Adam Thabet said as he waited his turn to cast a ballot. ‘‘We are free at last after years of fear. We knew this day would come, but we were afraid it would take a lot longer.’’
The election for a 200-seat parliament, which will be tasked with forming a new government, was a key milestone after a bitter civil war that ended Gadhafi’s four-decade rule. It was the first time Libyans have voted for a parliament since 1964, five years before Gadhafi’s military coup that toppled the monarchy.
But the desert nation of 6 million people has fallen into turmoil since Gadhafi was killed by rebel forces in his home city of Sirte in late October. Armed militias operate independently, refusing to be brought under the umbrella of a national army, and deepening regional and tribal divisions erupt into violence with alarming frequency.
Growing resentment in the east and the inability to rein in unruly militias have threatened to tear the country apart.
Some easterners boycotted the election and protesters torched ballot boxes in 14 out of 19 polling centers in Ajdabiya, said Ibrahim Fayed, a former rebel commander in the area.
On the eve of the vote, gunmen shot down a helicopter carrying polling materials near the eastern city of Benghazi, birthplace of last year’s revolution, killing one election worker on board, according to Saleh Darhoub, a spokesman for the ruling National Transitional Council. The crew survived after a crash landing.
The violence continued Saturday, with protesters, some armed, attacking polling centers in the early hours in the eastern cities of Ajdabiya, Brega and Ras Lanouf, ransacking them and setting ballot papers ablaze.
Reflecting the lawlessness that has plagued the country since Gadhafi’s ouster, protesters attacked a polling station in Benghazi only to be driven back by voters who fired their own weapons in the air, independent candidate Faiza Ali said.
‘‘Enough with the bloodshed,’’ she said.
Nouri al-Abar, the head of the election commission, told reporters in Tripoli that 94 percent of polling centers nationwide were open but acknowledged that ‘‘security conditions’’ prevented ballots from reaching some areas and ballots were destroyed in other cases. He did not provide further details.
The uprising against Gadhafi was inspired by the Arab Spring revolts that led to the successful ouster of authoritarian leaders in Tunisia, Egypt and later Yemen. But it morphed into outright civil war as armed rebels backed by NATO airstrikes battled Libyan regime forces for months.
Islamist parties also have gained influence in Libya and other nations following the ouster of authoritarian regimes run by strongmen like Gadhafi and Egypt’s Hosni Mubarak.
There are four major contenders in the Libyan race, ranging from the Muslim Brotherhood-linked party and another Islamist coalition on one end of the spectrum to a secular-minded party led by a Western-educated former rebel prime minister on the other.
Despite the divisions and unrest, the prevailing mood was one of triumph.
‘‘We are celebrating today and we want the whole world to celebrate with us,’’ Prime Minister Abdurrahim el-Keib said after he cast his ballot in Tripoli.
Voters flashed the V-for-victory sign as they entered polling centers. Motorists honked their horns as they drove past. Others shouted ‘‘Allahu Akbar,’’ or ‘‘God is Greater,’’ from their car windows.
‘‘This is history in the making,’’ 26-year-old medic Farid Fadil said. ‘‘We were ruled by a man who saw himself as the state.’’
The election lines brought together men, women in black abayas and children accompanying their parents. Some voters arrived at polling centers waving the Libyan red, green and black flag or wrapping it around their shoulders.
‘‘The turnout is extraordinary,’’ said Mohammed Shady, an election monitor. ‘‘Everyone is being very cooperative. They want the day to be a success and it will be.’’
Voters distributed sweets to mark the occasion and women hugged each other or sang as they waited in line. Others chanted ‘‘the martyrs’ blood will not go in vain,’’ a reference to the thousands of anti-regime rebels killed by Gadhafi’s forces. Others held pictures of loved ones killed in last year’s ruinous civil war.
‘‘Look at the lines. Everyone came of his and her own free will. I knew this day would come and Gadhafi would not be there forever,’’ said Riyadh Al-Alagy, a 50-year-old civil servant in Tripoli. ‘‘He left us a nation with a distorted mind, a police state with no institutions. We want to start from zero.’’
As he spoke said, a woman came out of the polling center ululating and flashing the purple ink on one of her fingers. The ink is used to prevent multiple voting.
Many in Libya’s oil-rich east feel slighted by the election laws issued by the National Transitional Council, the body that led the rebel cause during the civil war and assumed power after Gadhafi’s fall.
The laws allocate the east less than a third of the parliamentary seats, with the rest going to the western region that includes Tripoli and the sparsely settled south.
Flush with money, the Muslim Brotherhood’s Justice and Construction party has led one of the best organized and most visible election campaigns, and is hoping to become a political force in post-Gadhafi Libya like the Islamists of Egypt and Tunisia.
Three other parties also are expected to perform well: Former prime minister Mahmoud Jibril’s secular Alliance of National Forces, former jihadist and rebel commander Abdel-Hakim Belhaj’s Al-Watan and the National Front party, one of Libya’s oldest political groups, known for organizing several failed assassination attempts against Gadhafi.
The new parliament initially had two missions: to elect a new transitional government to replace the NTC and to name a 60-member panel to write the country’s constitution. Each of Libya’s three regions was to have 20 seats on the panel.
However, in a last-minute move, the NTC decreed that the constitutional panel will be elected by direct vote instead, leaving the parliament only with the task of forming a government and angering many candidates who campaigned largely on the basis of their role in overseeing the drafting of the constitution.