(Adds details, background)
By Ahmed Elumami
TRIPOLI, April 29 (Reuters) - Gunmen stormed Libya's parliament on Tuesday and opened fire, forcing lawmakers to abandon a vote on the next prime minister, witnesses said.
Parliament spokesman Omar Hmeidan said several people were wounded in the shooting by the gunmen, who were linked to one of the defeated candidates for prime minister. He gave no name.
Lawmakers fled from the building, witnesses said. The incident ended quickly but the vote was postponed until next week.
The government has been unable to control armed groups and Islamists who helped oust Muammar Gaddafi in 2011 but refuse to disarm and have carved out regional fiefdoms. Militias have repeatedly attacked the interim General National Congress (GNC) to make political or financial demands.
Hmeidan said deputies had started the final vote on a replacement for Premier Abdullah al-Thinni, who resigned two weeks ago saying that gunmen had attacked his family.
In the first ballot, businessman Ahmed Maiteeq came out on top among seven candidates. A second round between Maiteeq and the runner-up Omar al-Hasi had been meant to take place when the gunmen burst into the assembly.
Thinni had resigned just one month after his election, replacing Ali Zeidan, who was fired by deputies over attempts by rebels in the volatile east to sell oil independently.
The assembly is deadlocked between Islamists, tribes and nationalists, compounding a sense of chaos as Libya's fledgling army tries to assert itself against unruly ex-rebels, tribal groups and Islamist militants.
In February, it agreed to hold early elections in an effort to assuage Libyans frustrated at political chaos nearly three years after the fall of Gaddafi.
Deputies initially agreed to extend their term after their mandate ran out on Feb. 7 to allow a special committee time to draft a new constitution. But that move provoked protests from Libyans angry at the slow pace of political change.
Many people in the OPEC nation blame congress infighting for a lack of progress in the transition to democracy.
In another sign of trouble, the attorney general asked to lift the immunity of assembly president Nouri Abu Sahmain to investigate a leaked video showing him being questioned over a late-night visit by two women to his house, Benghazi MP Ahmed Langhi told Reuters.
The case has the potential to damage Abu Sahmain, who is the army commander and has quasi-presidential powers. He has disappeared from public view since the attorney general launched his investigation in March.
At the time of the incident in January, rumours surfaced that he had been briefly detained by a militia to question him about the women. He denied then he had been kidnapped. (Reporting by Ahmed Elumami; Writing by Ulf Laessing; Editing by Angus MacSwan)