The assailants attacked Masood Khalili late Sunday on a street in the centre of town, throwing him to the ground to steal his watch, a police spokeswoman said.
The ambassador, who was in Barcelona for celebrations marking war-torn Afghanistan's national day, suffered a leg injury but "is fine," according to a source at the Afghan embassy in Madrid.
The robbery comes as Barcelona, one of Europe's most visited cities, has seen a sharp rise in crimes, including several involving foreigners which have made global headlines.