Thani quit less than a week after parliament tasked him with forming a new cabinet and a month after it ousted his predecessor for failing to rein in the lawlessness gripping the North African country.
He said in a statement that he would not accept the premiership after a "traitorous attack" on himself and his family, but he would stay on in a caretaker capacity until a new prime minister is appointed.
Amid controversy over his appointment, Thani, who was defence minister under ousted premier Ali Zeidan, was named on Tuesday.
Thani said the attack yesterday had terrorised inhabitants of a residential district and "put the lives of some of them at risk", without giving specific details.
More From This Section
A source close to Thani told AFP that the incident took place on the road from the capital to its airport and caused no casualties.
As premier, Thani was faced with the daunting task of bringing former rebel brigades to heel following the 2011 NATO-backed uprising that ended Moamer Kadhafi's four-decade rule.
Omar Hmidan, a spokesman for the GNC, the country's highest political authority, said Thani was chosen after legislators failed to reach a consensus on other candidates.
He was given one week to form a new government.
The decision to confirm Thani was rejected as illegal by some legislators, who said it had not received the required number of votes.