Militiamen opened fire on the Libyan prime minister's office in the capital Tripoli on Tuesday, killing at least three people and wounding several others.

Prime Minister Abdurrahim al-Keib and other government officials are said to be unharmed. The casualties are believed to be members of Libya's security forces and other militia groups that came in to defend the prime minister's office.

The attackers are reportedly former rebels who fought to remove Col. Moammar Gaddafi from power last year and were disgruntled over unpaid stipends promised to them by the Libya's interim government.

Many men encircled the building and opened fire against it with weapons including anti-aircraft cannons, a government employee told Agence-France Presse. Some men entered the premises and fired from inside.

The fighting lasted several hours, but has now stopped. Defense Minister Osama al-Juwali has been negotiating with the militia groups, Libyan interim government spokesman Nasser al-Manaa told Al Jazeera.

The fighters are demanding cash handouts for their service as well as medical treatment abroad for those wounded in the uprising, BBC News reported.

Libya's interim government had suspended payouts to rebel fighters last month amid allegations of fraud.

Despite the bloodshed, the fighters received sympathy from some of Tripoli's inhabitants.

These militias made the revolution but they don't get paid, Moatasem Sotni, a hotel worker, told the Telegraph. There is nothing to fear from these guys. They want to be paid. There is plenty of money now in Libya, you can believe it, they should pay them.

The attacks come as general elections are due to be held in Libya to form a permanent government next month.