TRIPOLI, July 2 (Reuters) - Samia Sahli and her daughters browse the shops on a sunny day in Tripoli. A week before election day, the streets are filled with families, but the tranquil scene belies fears that Libya's first election in more than a generation could be marred by violence.

"I am very excited to vote ... but I'm scared of the security situation," Sahli, 30, said. "On the day ... I'll probably wait a bit to make sure there are no security breaches."

Libyans head to the polls on July 7 to elect a 200-strong national assembly that will, as well as appointing a prime minister and making laws, help draft a new constitution for the new country they hope to build. Almost 2.7 million people, or 80 per cent of those eligible, have registered to vote, suggesting huge appetite for democracy after 42 years of dictatorship.

But clashes in far-flung corners of the vast North African country and attacks on election organisers have raised doubts over the interim government's ability to police the polls, let alone deal with any gun-toting candidates who might dispute the outcome.

Almost a year after Muammar Gaddafi was ousted in a NATO-backed rebellion, the government has struggled to convince the myriad militias who helped topple him to lay down their weapons.

Though streets are mostly tranquil, gunfights can erupt suddenly. With so many weapons available, communities or individuals bearing grudges or involved in disputes make their own justice rather than turning to the weak police or courts.

On Sunday, armed protesters calling for more autonomy in Libya's east stormed the election commission in Benghazi, smashing election materials and breaking computer equipment.

Emad al-Sayeh, the deputy head of the commission, said there were not enough security forces deployed to stop the rioters so they were forced to step back and let them storm the building.

Benghazi, 1,000 km (320 miles) east of the capital and the cradle of Libya's revolution, has become a dangerous place. British and U.N. diplomatic convoys have been attacked, as have the Red Cross and the American and Tunisian consulates.

The attacks have been small, but raised fears of election-day violence in a city where Islamist militias have taken to the streets, tearing down campaign posters and condemning a new democratic system they say is alien to Islam.

LAYERS OF SECURITY

The leader of Ansar al-Sharia, Arabic for Partisans of Islamic Law, a small militia of Islamist hardliners, appeared on television to denounce elections, potentially discouraging voters and raising fears that polling stations may be targeted.

Wartime rebel prime minister, Mahmoud Jibril, who heads the National Forces Front coalition, said security was a challenge.

"There is always potential for some elements, whether from the previous regime or from those who don't believe in elections ... to do some (destabilising) activities," he said.

The government says it has a comprehensive security plan that will deploy between 30,000 and 40,000 personnel on the day.

"There will be several layers of security. There will be mostly police officers with no weapons in the polling stations," Deputy Prime Minister Mustafa Abu Shagur told Reuters.

"The Supreme Security Council will be the ones controlling the checkpoints around the polling stations and close to the polling stations. The military will be stationed in the 13 (voting) districts on standby in case they need to intervene."

But a recent uptick in violence suggests the security challenges may be too formidable for the government to handle. If many Libyans are too afraid to vote, feel intimidated into voting one way or another or feel the ballot has not been organised fairly, it could undermine the legitimacy of the whole election and plunge Libya into a new cycle of instability.

The challenge was highlighted last month when a disgruntled militia was able to drive past security forces and seize control of Tripoli international airport for hours. Volunteer brigades were forced to step in to help it take back control.

Mokhtar Lakhdar, head of the Zintani militia that controlled the airport before handing it over to government forces in April, said he would boycott the vote as no election could be deemed representative until the country had stabilised.

"The government needs to work on building security first before working on elections," he told Reuters.

In Western Libya, more than 100 people have been killed in clashes between fighters from Zintan and the al-Mashashia tribe, which did not join last year's rebellion. And in the south, clashes have repeatedly erupted between Arab ex-rebels and non-Arab Tibu tribes. Government forces have struggled to cope.

OBSERVER MISSIONS LIMITED

While the European Union, the Arab League, the African Union and the Carter Center are sending in observers, security fears mean many will stay away from the most remote or unstable areas, where violations are most likely to take place.

"Our mission is limited and it can't provide a comprehensive view of the process," said the Carter Center's Alexander Bick.

With so many groups already opposed to the elections and so many challenges facing voters and organisers on the day, many candidates are likely to appeal the outcome of the vote.

Unlike Tunisia and Egypt, where this was done through the election commission or the courts, in Libya people may be tempted to reach for their guns.

"The police force is just too weak at this point in terms of communication, command structure and resources, and there are just too many militia elements out there," said Ian Smith, head of U.S-based democracy promotion group International Foundation for Election Systems in Libya.

"There is the barest minimum of security plan so far ... The elections commission is in discussions now about what to do in the event that there is a security incident at a polling station ... These things need to be worked out." (Additional reporting by Marie-Louise Gumuchian; Editing by Lin Noueihed and Robin Pomeroy)