The Islamic State group claimed deadly suicide car bombings in Libya Friday as the international community struggles to find ways to end the chaos in the North African nation.
The United States and United Nations denounced the "terrorist" attacks, echoing Libya's beleaguered internationally recognised government, which declared seven days of mourning.
Washington and the UN also called for the resumption of talks between Libya's rival factions for a political solution to the deepening crisis.
The health ministry said 40 people, including six Egyptians, were killed and 41 wounded in the town of Al-Qoba.
Security sources said simultaneous attacks targeted a petrol station packed with motorists, a police headquarters and the area around the home of parliament speaker Aquila Salah Issa, who was away at the time.
IS claimed two attacks, which it said was to avenge Egyptian and Libyan air strikes this week on the jihadist stronghold of Derna.
It said it targeted forces of General Khalifa Haftar, who launched a campaign in May to rid Libya of Islamist militias who have thrived since the 2011 NATO-backed uprising that ousted dictator Moamer Kadhafi.
"This is a message to anyone who is tempted to attack the soldiers of the caliphate (IS) or any Muslim," IS said.
Egypt, coordinating with Haftar's forces, pounded jihadist positions in Derna Monday after IS released a video of the beheading of 21 Coptic Christians, most of them Egyptian.
Egypt called for international action against IS and echoed appeals by Libya's recognised government to lift a UN arms embargo to help it tackle the jihadists.
But Western and Arab states flinched at the suggestion of force, and UN Libya envoy Bernardino Leon said Wednesday the only cure for Libya's trauma was political.
Leon's office deplored the "terrorist bombings, saying the "best response to counter terrorism and violence is for the Libyans to forge ahead with the search for a political solution."
- 'Fight these groups' -
Washington called on Libyans to resume UN-brokered talks that would lead to the creation of a national unity government.
"The best way to counter the terrorists... is to have Libyans build the national consensus that they need to fight these groups, not each other," said State Department spokeswoman Jen Psaki.
And White House spokesman Josh Earnest said "it's a situation that we're going to continue to monitor. But while we do that, we're going to continue to be supportive of the UN-led dialogue."
Signup to our newsletter and follow us on Facebook and Twitter!
Libyan lawmaker Abu Bakr Beira said the United Nations has invited Libya's rival parliaments to a new round of talks after a first session of indirect negotiations on February 11.
He did not provide a date, but said the talks would be held in Morocco.
Last week's talks were the first to involving the recognised parliament and the rival General National Congress, which has ties to Islamists.
The government pledged Friday that the army "will retaliate firmly and will step up its operations against the strongholds of Daesh," the Arabic acronym for IS.
- IS surge -
Analysts have warned that IS was expected to gain more strength in Libya, after having seized swathes of Syria and Iraq, and said the international community was running out time.
"The threat of Islamic State in Libya is set to increase exponentially," analyst Mohamed El-Jareh, from the Atlantic Council's Hariri Centre for the Middle East, warned Friday.
Others have cautioned that military action could pour fuel on the fire in Libya, which has been awash with weapons since Kadhafi was ousted and killed.
Since then, Libya's beleaguered authorities have been struggling to rein in powerful armed militias who are battling for power and the country's oil wealth.
Recent attacks in Libya claimed by IS have boosted concern that some militias have in fact pledged allegiance to the Sunni Muslim extremists.
In January IS launched a brazen assault on a Tripoli hotel that killed nine people, five of them foreigners.
On Thursday, gunmen seized Sirte university and a conference centre, days after taking control of state radio and other government buildings in the coastal city, witnesses said.
They said IS set up a headquarters in Sirte, and the group is also said to have cells in Libya's vast southern desert where they run training camps.
Sirte, Kadhafi's hometown, is a stronghold of Ansar al-Sharia, classified as a terrorist organisation by the United Nations and known to be close to Al-Qaeda.
Ansar al-Sharia has also a presence in Benghazi, where Haftar has been battling Islamists, as well as in Derna.
Its ties with IS are unclear although several of its members are reported to have defected to the group.