A Libyan army spokesman says two car bombs have gone off in the eastern city of Tobruk, where the nation's elected parliament is temporarily located, causing casualties.

Mohammed Hegazi says the bombs exploded in front of an oil institute early on Wednesday but that it was not immediately clear how many people were killed.

He says the attack meant to "terrorize" state institutions and the parliament, as well as deliver a "we are here" message from militants.

Hegazi says the blasts have the hallmarks of extremists from the eastern city of Darna who have pledged allegiance to the Islamic State group.

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.