PHOENIX — A federal judge on Thursday threw out a challenge to a 2011 Arizona law banning abortion based on the race or sex of the child.

U.S. District Judge David Campbell said the two groups who filed suit contend the statute “stigmatizes and denigrates their members on the basis of race and gender,’’ based on comments by a sponsor that Asian women abort girls because they prefer boys and black women are more likely to be talked into terminating a pregnancy.

But Campbell said there is nothing in the claim that shows any individual has suffered a personal injury because of what the Legislature enacted, beyond psychological consequences. And that, he said, means they have no right to challenge the law.

The 12-page ruling does not mean the law is constitutional. That remains an open question until a woman who is denied an abortion under the law, and therefore is directly affected, challenges it. A doctor prosecuted for performing such an abortion also would have legal standing.

Dan Pochoda, legal director of the American Civil Liberties Union of Arizona, which filed the lawsuit, said in a prepared statement his organization already is looking for legal ways “to put an end to this unconstitutional, bigoted law.”

While the dismissal was on procedural grounds, the anti-abortion Alliance Defending Freedom claimed Thursday’s ruling as a victory.

“There is nothing medically necessary or constitutionally protected about an abortion that is committed on the basis of sex or race,” said Casey Mattox, the organization’s senior counsel.

Mattox acknowledged the historic 1973 U.S. Supreme Court ruling recognizing that women have an absolute right to terminate a pregnancy prior to the viability of a fetus. But he insisted that case and subsequent rulings are not a license to abort a fetus for a discriminatory purpose.

“I think the state certainly has a role to step in,” Mattox said. “When you’re talking about lives being eliminated for discriminatory reasons, nothing in the Supreme Court jurisprudence protects that.”

The law makes it a felony, punishable by up to seven years in prison, for a doctor to terminate a pregnancy, “knowing that the abortion is sought based on the sex or race of the child or the race of the parent of that child.”

The law requires doctors to sign an affidavit saying they are not knowingly terminating the pregnancy because of the child’s sex or race. That affidavit becomes part of the doctor’s medical record, which can be accessed by the Arizona Medical Board and, ultimately, by prosecutors.

There is no record of anyone having been charged under the law.

In pushing the legislation, Rep. Steve Montenegro, R-Litchfield Park, said there was evidence that blacks have a higher abortion rate than other races. He called those who perform such procedures “the people behind genocides.”

Montenegro also said women in Asian countries, preferring boys, will abort girls.

There was, however, no testimony any of that is happening in Arizona.

The lawsuit filed by the NAACP and the National Asian Pacific American Women’s Forum charged violations of the Equal Protection Clause of the U.S. Constitution.

“Its purpose is to reduce the rate or number of black and API (Asian and Pacific Islander) women who have abortions, but not women of any other race,” the legal papers said. It also charged that the law is “based on racist and discriminatory stereotypes” about both groups.

Campbell, in Thursday’s ruling, did not address those contentions. Instead, he said they have no right to sue in the first place.

“Plaintiffs do not claim that their members have been denied abortions because of the act or face prosecution or liability under the act,” the judge wrote.

Instead, Campbell said, the basis of the lawsuit “rests exclusively on alleged stigma and denigration issues, the same generalized and abstract injuries that federal courts have long rejected as a basis for constitutional standing.”

Pochoda, in his statement, said the ACLU remains convinced the statute will be overturned.

“The U.S. Constitution flatly prohibits states from passing laws founded on racist ideas” he said.