A federal judge has ruled that an upstate New York town violated a Connecticut man's First Amendment rights when he was arrested on a charge of aggravated harassment for writing profanities on a $175 speeding ticket three years ago.

In ruling issued last week, U.S. District Judge Cathy Seibel allowed Willian Barboza's lawsuit against the village of Liberty, N.Y. to proceed on claims the town of approximately 10,000 people 100 miles northwest of New York City failed to properly train police officers about free speech.

The New York Civil Liberties Union, which represented Barboza, publicized a transcript of the trial Tuesday.

Barboza, who was 22 at the time of his initial arrest, was stopped for speeding on Route 17 in May 2012, according to The New York Times. On his payment form, Barboza crossed out the name of the town and wrote "Tyranny" in its place. He then wrote the phrase "F--- your s----y town b----es."

When the form arrived at the Liberty town clerk's office, one of the workers, all of whom are women, told a local judge Barboza's profane phrase upset and alarmed them, according to court records. The judge referred Barboza's speeding payment form to a prosecutor and ordered Barboza to appear in court.

When Barboza showed up, the local judge reprimanded him for his comments on the form and told him he would be arrested, Seibel said in her ruling. Barboza was handcuffed and taken away before his release on $200 bail.

Seibel's ruling noted the criminal charge eventually was dismissed in 2013 on First Amendment grounds. She said Barboza's phrase was crude and offensive to some but "did not convey an imminent threat and was made in the context of complaining about government activity."

"That the court clerks who received plaintiff's message were apparently alarmed by it does not alter the analysis," the judge added.

In an NYCLU release, Barboza was quoted as saying he was treated as a criminal for a "few harmless words."

"Instead of protecting freedom of speech, government officers in Liberty handcuffed me, arrested me for a crime and almost sent me to jail because I harmlessly expressed my frustration with a speeding ticket," he said.

Barboza's case is not unique in Liberty. Seibel said that between 2003 and 2012 as many as 63 arrests by police officers in the village had occurred "because of the use of vulgar words in what may be perceived as a threatening context." She said one arrest occurred when a defendant called someone a slut, another resulted from someone talking about sexual acts on a police department phone line and another came after a defendant threatened to kill someone's dog.

Seibel added the trial would include a damages phase for a prosecutor who is not protected by immunity because his actions were unreasonable.

Barboza's lawsuit had sought unspecified damages.

The Associated Press contributed to this report.