The incident happened Wednesday when Mariano Rajoy was mingling with crowds in Pontevedra city in his northwestern fiefdom of Galicia on the latest stop of his push for re-election in Sunday general elections.
The teenager approached and hit the prime minister hard on the left side of his face, knocking off and breaking his glasses before being wrestled to the ground by Rajoy's bodyguards.
A photo posted after the incident pictured Rajoy without his glasses, red marks on the left of his face and neck, but the premier was not badly hurt and continued his walk through the city.
"He will be locked up in the centre... For a maximum period of six months," it said, awaiting a final ruling on the case by a juvenile court in Pontevedra.
Also Read
Rajoy went on to appear as planned at a campaign meeting Wednesday evening, and travelled to Brussels yesterday for the last EU leaders' summit of his four-year term.
Spanish television showed Rajoy surrounded by Germany's Angela Merkel and Britain's David Cameron on the sidelines of the summit.
Merkel was pictured reaching out for Rajoy's left cheek, in what was interpreted as a sign of concern for the Spanish leader after the assault.