Tunisian Prime Minister Hamadi Jebali resigned Tuesday after failing to form a government amid conflict between his Islamist allies and their secular opponents.

Jebali had threatened to quit if his plan for a nonpartisan Cabinet of technocrats to lead the country into early elections foundered, Reuters reported.

It turned out to be his own party, the Islamist Ennahda, that rejected his initiative.

"I vowed that if my initiative did not succeed, I would resign and ... I have already done so," Jebali told a news conference Tuesday evening after meeting with President Moncef Marzouki.

Meanwhile, Standard and Poor's said it had lowered its long-term foreign and local currency sovereign credit rating on Tunisia, citing "a risk that the political situation could deteriorate further amid a worsening fiscal, external and economic outlook."

Tunisia's deepest crisis since the revolution two years ago began Feb. 6, when secular opposition politician Chokri Belaid was gunned down outside his home in Tunis.

No one claimed responsibility, but it enraged secularists who believe Jebali's government has failed to contain religious extremists. Protesters poured onto the streets, and Marzouki's secularist party threatened to quit the government.

Jebali said he would try to form a Cabinet of apolitical technocrats to restore calm and call new elections. Several secular politicians backed the plan but Ennahda, currently the largest party, vetoed it.

Marzouki is likely to reappoint him as caretaker premier before a new leader is appointed. Ennahda leader Rached Ghannouchi has said he wants to see Jebali head a new coalition, and Marzouki was to consult with Ghannouchi on Wednesday.

But Jebali said he would not lead another government without assurances on the timing of fresh elections and a new constitution.

No government would be viable without Ennahda's blessing given its strength in parliament.

Ghannouchi has said it is essential that Islamists and secular parties share power now and in the future, and that his party was willing to compromise over control of important ministries such as foreign affairs, justice and interior.

"Ennahda is in negotiations with political parties to form a national coalition government," Fethi Ayadi, a senior Ennahda official, told Reuters.

Iyed Dahmani, a leader of the secular Republican Party, said some kind of agreement was vital.

"We are in real trouble, politically and economically," he said.

Tunisia has been negotiating with the International Monetary Fund for a $1.78 billion loan and politicians said Jebali's inability to re-establish a functioning government had slowed efforts to restore normality.

"Our people are disillusioned by the political class. We must restore confidence," Jebali said, according to the Guardian. He added that his resignation "does not mean the failure of Tunisia or the failure of the revolution" but warned the cabinet to do the "utmost to ensure that the state continues to function".

Tunisia overthrew dictator Zine al-Abidine Ben Ali in January 2011, which sparked the Arab Spring. It held its first free elections 10 months later and was considered the model for democratic transition in the region. The new government, led by Ennahda, was to sit for a year and agree on a new constitution and fresh elections. But the year's deadline has passed, the coalition has bickered and struggled to govern.

The economy, which relies heavily on exports to Europe as well as tourism, has been battered by unrest and badly hit by financial crises facing many of its European trading partners.

Unemployment is at around 18 percent, and inflation has hit 10 percent. The economy contracted by 1.8 percent in 2011 and saw a sluggish 2.4 percent growth in 2012. S&P said the current instability suggests that growth will not recover in 2013 either.

"We expect lower tourism receipts, combined with a widening trade deficit, to result in current account deficits that will remain in excess of 5 percent of GDP through 2016," the ratings agency's statement said. "We anticipate that Tunisia's economic recovery will be slow, particularly given the weak economic conditions in the EU."