Libyans defied violence and boycott calls to rush to the polls in their first free national election in 60 years.
While the mood was jubilant in the capital Tripoli, the east of the country was more troubled as anti-poll protesters seeking greater autonomy for a region that is home to the bulk of Libya's vast oil resources sought to disrupt the vote.
One man was shot dead by a security guard as he tried to steal a ballot box in the eastern town of Ajdabiya and there were stand-offs in Benghazi, the cradle of last year's uprising, as protesters stormed several polling stations.
But as voting closed around the country, authorities said 98% of poll centres had opened at some point during the day for the election for a 200-head assembly that will name a prime minister and pave the way for parliamentary elections in 2013.
"I am a Libyan citizen in free Libya," said Mahmud Mohammed Al-Bizamti at one centre in Tripoli.
"I came today to be able to vote in a democratic way. Today is like a wedding for us."
Zainab Masri, 50, a teacher in the capital, said she felt overwhelmed after voting for the first time in her life.
"I can't describe the feeling. We paid the price - I have two martyrs in my family.
"I am certain the future will be good, Libya will be successful," she said, proudly showing off her inked finger that showed she had voted.
The election commission said 1.2 million of some 2.8 million registered voters had cast their ballot by 4pm, with others expected to turn out in the evening once the searing heat had abated.
Candidates with Islamist agendas dominate the field of more than 3,700 hopefuls, suggesting Libya will be the next Arab Spring country - after Egypt and Tunisia - to see religious parties secure a grip on power.
In Benghazi, protesters stormed a polling station just after voting started and set fire to hundreds of ballot slips in a public square in a bid to undermine the election's credibility.
Witnesses said at least four polling stations had been hit in such attacks. One man was shot in the arm and taken to hospital with heavy bleeding after a clash between vote boycotters and those in favour of the election.
"There wasn't enough security at the station to stop the attackers," Nasser Zwela, 28, told Reuters, saying protesters armed with assault rifles had stormed one polling station and shouted at everyone to stop voting.
Voting with tears
But Western supporters of the NATO-backed uprising that overthrew Gaddafi dismissed suggestions the setbacks proved the election lacked legitimacy.
"I think the best thing for Libya is not to have Muammar Gaddafi massacring his own people ... So far, all indications are that this election was free and fair," US Senator John McCain said in Tripoli after being briefed by poll officials.
UN envoy to Libya Ian Martin told reporters in the capital: "I think we can see already that the problems are in a small enough proportion of the polling centres that it's not going to undermine the overall credibility of the election."
Some voters struggled with procedures for casting their ballot. In one central Tripoli district, two women disappeared into a voting booth together before an election worker hurriedly explained they must vote alone.
"Some of these women are crying as they vote. It is such an emotional day," said one poll official.
Polls started closing at 8pm but partial results are not due until Sunday and a full preliminary count is not expected until Monday at the earliest.
Many easterners are angry that the east has been allotted only 60 seats in the assembly compared with 102 for the west.
On Friday, armed groups shut off half of Libya's oil exports to press demands for greater representation in the assembly. At least three major oil-exporting terminals were affected.
"The country will be in a state of paralysis because no one in the government is listening to us," Hamed al-Hassi, a former rebel who now heads the High Military Council of Cyrenaica, the name of the eastern region, told Reuters.
Port agents said the oil depot closures would last 48 hours but the government sent a team on Saturday to negotiate a full reopening of a sector that provides most of Libya's revenues.
Analysts say it is hard to predict the political make-up of the new assembly, but parties and candidates professing an attachment to Islamic values dominate and very few are running on an exclusively secular ticket.
The Justice and Construction offshoot of Libya's Muslim Brotherhood is tipped to do well, as is al-Watan, the party of former CIA detainee and Islamist insurgent Abdel Hakim Belhadj.