Mayor Josu Bergara was recorded in a meeting last year boasting that he had made sure "the scum no longer come" to his northern town of Sestao.
Five Romanian families lodged a complaint against him in court, accusing him of illegally refusing to register them as residents in the Basque town.
They submitted a video of his outburst as evidence of racism to support their case, said the campaign group SOS Racismo, which aided the families.
"The scum no longer come to Sestao. I make sure they leave, by thumping them," he was recorded saying at a meeting in June 2013.
Also Read
He said he had been referring to "delinquents" in general, not Romanians in particular as the plaintiffs alleged.
"I acknowledge that the comments that have come to light were inappropriate. We want Sestao to be a multicultural, hard-working and civil place," he said.
But he added: "We cannot allow people to come here to rob. In the video I was referring to delinquents and antisocial people."
SOS Racismo said it was "unacceptable that his comments be played down, even if the apology is sincere".
Romanians are the biggest foreign nationality group in Spain. They numbered about 795,000 in 2013, according to the National Statistics Institute.