(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.
He warned in November that the situation was a crisis and asked for the United Nations to intervene. And he also made more controversial comments about migrants, describing some in the group as violent and vulgar, vowing that local authorities would crack down on anyone who was caught breaking the law.
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.
Last week, a Mexican district court judge ruled that Gastelum can't make any public declarations that have "as a goal -- either implicit or explicit -- transmitting a negative message about migrant people," according to a government statement describing the ruling. The court ordered municipal authorities in Tijuana to "refrain from issuing statements contrary to the protection of and respect for migrant people."
The mayor revealed the judge's order in a Facebook post, calling it censorship.
A spokeswoman for the mayor's office told CNN Friday that the judge's order came after a civil association filed a complaint. Gastelum formally appealed the order on Wednesday, the spokeswoman said, and is awaiting an appeals court's decision.
Thursday, the mayor shared another Facebook post vowing to press forward with the appeal.
"I will appeal the order given by the federal judge that tries to censor our freedom of expression," he wrote. "Here there is a mayor that defends Tijuana and a lawyer who knows the law well. I will keep you posted."