(CNN) A Mexican federal judge has ordered Tijuana's mayor not to spread negative messages about migrants.

Mayor Juan Manuel Gastelum says he's appealing the ruling, which he argues violates his right to free speech.

Gastelum made international headlines when he spoke out as thousands of migrants who'd been traveling in large groups known as caravans began arriving in his city.

Immigrant rights advocates decried what they said was nativist rhetoric from the mayor, accusing him of fueling tensions rather than easing them. Gastelum has maintained he's simply standing up for the rights of Tijuana's residents.