The American Civil Liberties Union has filed a lawsuit on behalf of two women, both U.S. citizens, who say a border patrol agent unlawfully detained them outside a Montana convenience store because he heard them speaking Spanish.

>> Read more trending news

Ana Suda and Martha Hernandez were at the convenience store when the border agent, identified as Paul O'Neal, approached them, according to the federal lawsuit filed Thursday. O'Neal allegedly commented on Hernandez's accent and then asked the women where they were born. Hernandez was born in California and Suda was born in Texas, the ACLU said.

The women showed O'Neal their valid Montana driver's licenses. At that point, the lawsuit said O'Neal detained the women in the convenience store's parking lot. The women then began taking video of O'Neal on their cellphones.

"Ma'am, the reason I asked you for your ID is because I came in here and I saw that you guys are speaking Spanish, which is very unheard of up here," O'Neill said in the video.

The two were detained for about 40 minutes, according to the lawsuit.

The women’s ACLU lawyers said O’Neal should have let them go as soon as they identified themselves as U.S. citizens. In detaining them, the lawsuit argues that O’Neal violated the women’s Fourth Amendment rights barring unreasonable search and seizures.

The lawsuit also argues the women were racially profiled, a violation of the Fifth Amendment right to due process.

Customs and Border Protection spokesman Jason Givens declined to comment on the lawsuit, but said in an email to The New York Times, "lack of comment should not be construed as agreement or stipulation with any of the allegations."

In May, CBP spokesman Andrew Meehan told ABC News that speaking Spanish alone "is not enough" to pull someone over or ask for ID. However, he said it's possible O'Neal "very well could have been following procedure."

According to a statement from the ACLU, the experience was "humiliating and traumatizing" for the women. It said the women have been "shunned and harassed" by other town residents.

“This unjustified and discriminatory seizure is part of a longstanding pattern of abuse by local CBP agents. It is illegal and must stop,” said Caitlin Borgmann, executive director of the ACLU of Montana.

Suda and Hernandez are asking for an unspecified amount of money in compensation, punitive damages and a judge's order barring border officials from stopping or detaining anyone based on race, accent or language, according to the lawsuit.