Two US citizens are suing US Customs and Border Protection (CBP) after they were detained in Montana for speaking Spanish.

Ana Suda and Martha Hernandez were held by a CBP officer last May after he heard them speaking Spanish in a grocery store.

Agent Paul O'Neal questioned the US citizens for about 40 minutes and asked to see identification.

Both believed they were being detained, according to court documents.

The American Civil Liberties Union (ACLU) filed the suit on behalf of Ms Suda and Ms Hernandez.

"Speaking Spanish is not against the law," ACLU staff attorney Cody Wofsy wrote in a press release, arguing this CBP action "reflects an out-of-control agency emboldened by a vehemently anti-immigrant administration."

The lawsuit seeks to stop the CBP from detaining anyone without cause for speaking Spanish or for their accent, as well as compensatory and punitive damages.

Ms Suda, who was born in Texas, recorded the original incident on her phone. Ms Hernandez was born in California.

Agent O'Neal says in the footage that he was asking for their identification because they were "speaking Spanish, which is very unheard of up here".

Once the incident went public the agency said it was "committed to treating everyone with professionalism, dignity and respect".

The CBP's nondiscrimination policy prohibits using racial and ethnic stereotypes to conduct stops or searches, but the language over how agents decide to question people is vague.

Census data says about 41 million people speak Spanish at home in the US.

The country is the second largest Spanish-speaking nation in the world, with more Spanish speakers than Spain itself when bilingual people are included.