The officers, members of a crack rural security squad, were on patrol in the notoriously dangerous District 3 of the country's capital Bangui when the incident occurred.
At around 8pm, the agents stopped a man armed with an AK-47 machine gun, demanding to see his ID, Spain's 20 minutos reported.
The man then fled, and a shoot-out ensued, with the Spanish officers taking cover in their vehicles.
When the Spanish police fled, they were attacked with grenades, some of which impacted against the rear of their vehicles.
They managed to escape the neighbourhood without injuries.
Some 20 officers of the Civil Guard's Rural Action Group are currently deployed in the Central African Republic, supporting local police in security efforts.
Local police forces have been seriously diminished because of clash with various militant groups, including the Anti-Balaka Christian insurgents.