CAIRO — Two car bombs and an explosion struck Wednesday in two eastern Libyan cities that are temporary homes to the nation's elected parliament and government, killing four and injuring 21 others, officials said.

Libyan warplanes responded with airstrikes, bombing Islamist militia positions in their stronghold in the eastern city of Darna.

The near-simultaneous attacks targeting elected authorities were a worrisome new development in the turmoil roiling Libya, where hundreds of people have been killed in recent months.

The two car bombs went off in Tobruk, in front of an oil institute, army spokesman Mohammed Hegazi said. One person was killed and at least 21 were injured, including three in critical condition, according to hospital records.

Hegazi said the attack was meant to "terrorize" state institutions and the parliament, as well as deliver a "we are here" message. He blamed militants based in the eastern city of Darna who have pledged allegiance to the Islamic State group.

Simultaneously an explosion hit an air base used for civilian flights in the eastern city of Bayda, which is home to the Libyan government, according to an airport employee. Three troops were killed in the blast, another official said.

Shortly after the bombings, the Libyan army launched airstrikes on the city of Darna, killing three of the militia members, the official added.

The official and the employee spoke on condition of anonymity because they were not authorized to speak to the press.

Libya's elected parliament was forced to relocate to the far-eastern city of Tobruk after Islamist-allied militias took over the country's capital, Tripoli, and the second-largest city of Benghazi after fierce clashes. Fighting is still underway in most of the country's east, and another frontline has opened in the far west of Libya amid clashes between rival militias.

Oil-rich Libya is going through its worst spasm of violence since the ouster and killing of long-time dictator Moammar Gadhafi in 2011.

After seizing Tripoli in August, Islamist-allied militias from the powerful western city of Misrata revived an old parliament and formed a self-proclaimed government in the capital.

In October, Prime Minister Abdullah al-Thinni of the internationally recognized government joined ranks with former army Gen. Khalifa Hifter in a military campaign that is fighting to retake Benghazi from the militants.