The incident, which was initially thought to be an accident, took place on Friday afternoon at Honey’s Bar in Torre-Pacheco, some 30 kilometres (18 miles) from the southeastern town of Murcia.
The driver, whom police identified as a 30-year-old Moroccan national, also died in the incident in which two other people were also injured.
The National Court “has opened proceedings to investigate the incident as terrorism,” the judicial source said.
The court did not provide any information about the investigation which is looking into the possible motivations of the driver.
Spanish media said the driver appeared to have suffered stab wounds and had a letter in the car containing a jihadist message, but the judicial source could not confirm such details.
In a posting on Facebook, Honey’s Bar, which is popular with British residents in Spain, said it had closed for the weekend out of respect for the victim, whose identity remains unclear.