A New York man arrested after he gave the finger to a police officer can sue police for malicious prosecution, a federal appeals court ruled Thursday, overturning a lower-court decision that deemed the officer's response reasonable.

In its decision, the 2nd U.S. Circuit Court of Appeals said that giving someone the finger is an "ancient gesture of insult" and "is not the basis for a reasonable suspicion of a traffic violation or impending criminal activity."

The incident took place in May 2006, court documents say, when John Swartz and his wife, Judy Mayton-Swartz, were driving through the upstate village of St. Johnsville, N.Y., to the home of Judy’s son.

Swartz was in the passenger seat when he noticed a local officer, Richard Insogna, in a police car using a radar device. Expressing his displeasure, Swartz reached "his right arm outside the passenger side window and extending his middle finger over the car’s roof," according to court documents.

The couple continued their drive. They were not speeding or committing other traffic violations, but upon reaching their destination and getting out of the car, they saw an approaching police car with its lights flashing.

Ordering them to get back into the vehicle, Insogna told the couple this was a traffic stop and requested their documents. Swartz told his wife not to show the officer anything, prompting Insogna to say, "Shut your mouth, your ass is in enough trouble." Then, after checking the woman's license and registration, Insogna called for backup, according to court documents. Three other officers soon appeared.

After being told he and his wife were free to go, Swartz tried to speak with Insogna, but the other officers stepped in front of him.

Swartz was arrested after he either muttered or shouted, depending on whose account one reads, that he felt "like an ass."

At the station, he was told he had been arrested for disorderly conduct, a charge that was later dismissed.

Swartz's lawyer, Elmer Robert Keach III, praised the court's decision, The Associated Press reported.

"It reaffirms that just because you insult a police officer [it] doesn't give that police officer the right to detain you or arrest you and take away your liberty," Keach told The AP, calling the decision an "important victory for civil rights."

A lower-court in Albany had previously dismissed the couple's claim because police insisted they had stopped the couple out of concern for the woman's safety.

In his deposition, Insogna said Swartz's gesture made him "concerned for the female driver, if there was a domestic dispute.”

But the appeals court deemed his conclusion unreasonable. "Indeed, such a gesture alone cannot establish probable cause to believe a disorderly conduct violation has occurred," court documents read.

The court added, however, that the merits of Swartz's lawsuit, which seeks unspecified damages, still must be litigated at a separate trial.

More content from NBCNews.com:

Follow US news from NBCNews.com on Twitter and Facebook