The official, who works for a unit tasked with protecting embassies, said the attack in central Tripoli seriously wounded a guard and two passers-by and damaged the building and parked cars.
The assailants threw "a bag full of explosives from a passing car at a police car parked near a guard post", he said.
The Algerian embassy, like most foreign missions in the Libyan capital, was closed last year as militias battled for control of the city.
Today's attack comes a day after Fajr Libya announced a ceasefire in the oil-rich North African country, hours after an agreement at UN-brokered peace talks between the warring factions in Geneva.
Libya has been wracked by conflict since the overthrow of dictator Moamer Kadhafi in a 2011 uprising, with rival governments and powerful militias battling for control of key cities and the country's oil riches.