Libyan Interim Prime Minister Abdullah al-Thinni handed his resignation to parliament on Sunday after less than two weeks in the post, saying gunmen had tried to attack his family, Reuters reported.
His resignation adds to growing chaos in Libya, where the fragile government has struggled to overcome political rivalries and brigades of former rebels nearly three years after the fall of Muammar Gaddafi in a NATO-backed rebellion.
In a letter sent to the General National Congress and published on the government website, Thinni said he and his family had been victim of a "cowardly attack" and he could not "accept to see any violence because of my position".
"I have decided therefore to present my apologies as I cannot accept this temporary position," the letter said, without giving details about the incident.
A spokesman for the prime minister's office said no one had been injured in the attack, which he described as a "near miss" outside Thinni's family home.
With no real national army, OPEC member Libya is struggling with its transition to democracy as the brigades of former rebels who once fought Gaddafi refuse to disarm and often challenge the state's authority.
Thinni was appointed earlier this month as interim prime minister with a mandate for just a few weeks. It was extended by the GNC last week on condition that he formed a new government in an attempt to bring some stability.
If his resignation is accepted, the GNC must appoint another premier. The legislature, deeply unpopular with many Libyans who say it has failed to advance a transition to democracy, is deadlocked between Islamist and nationalist parties.
The GNC voted out Thinni's predecessor, Ali Zeidan, after he failed to end a crisis with federalist rebels who had occupied three vital oil ports for months. Thinni's government reached an agreement with them to reopen the ports.
Zeidan, who himself was briefly abducted by a militia last year, fled to Europe after he was removed from his post. He had often complained of being unable to govern because of political rivalries and pressure from militias.
Follow us on Twitter @TRENDNewsAgency