A car bomb exploded in the Libyan capital of Tripoli near a building that houses the Canadian Embassy, but an official says the office was closed at the time and all staff are safe.

"We take the safety and security of our staff abroad very seriously," Rick Roth, press secretary to Foreign Affairs Minister John Baird, said on Twitter. "We are monitoring events closely and taking [appropriate] security measures."

Along with the Canadian Embassy, Tripoli Towers houses the offices of several companies including foreign airlines. (Google)

The explosion occurred in the car park of a residential compound next to Tripoli Towers, where both the British and Canadian embassies are located, according to a Reuters report citing an unnamed witness.

"I heard an explosion and looked outside and saw a car in flames," he told Reuters.

Along with the Canadian Embassy, Tripoli Towers houses the offices of several companies including foreign airlines.

The explosion occurred during the mid-afternoon when many offices are closed for the month-long Islamic holiday of Ramadan.

There's been a spate of bombings in recent months in Libya. In April, the French embassy in Tripoli was bombed, while in the volatile eastern city of Benghazi, four Americans, including the ambassador, were killed on Sept. 11 last year.