France's embassy in Libya was hit by an apparent car bomb, injuring two French guards.

It was the first assault on a diplomatic mission in Tripoli since the end of the 2011 war that ousted Muammar Gaddafi.

There have been several similar attacks, notably in the eastern city of Benghazi, where the US ambassador and three other Americans were killed last September.

Al-Qaeda's north African arm AQIM has warned of retaliation for France's intervention in Mali but there was no indication as to who was behind today’s explosion.

A large chunk of the wall around the compound collapsed and one corner of the embassy building had caved in.

Office cabinets lay scattered on the ground outside and water from a burst pipe ran down the street. Residents pointed to shrapnel belonging to the car they said had exploded.

French President Francois Hollande condemned the attack.

"France expects the Libyan authorities to shed light on this unacceptable act so that the authors are identified and brought to justice," he said in a statement.

Foreign Minister Laurent Fabius, due in Tripoli today, said carnage was avoided only because the attack happened shortly before embassy staff would have been arriving for work.

"This is an attack that targets not only France but all countries that fight against terrorist groups," he said on BFM TV, adding that security would be stepped up across the region.

Mr Fabius said one of the two guards had been injured seriously and would be operated on in Tripoli.