Three Iowa Supreme Court judges who ruled that the state’s ban on gay marriage was unconstitutional have been ousted by voters after a campaign by anti-gay groups.

Supreme Court Chief Justice Marsha Ternus and associate justices Michael J Streit and David L Baker were voted out of office yesterday, in what gay marriage opponents are hailing as a victory.

Anti-gay marriage groups including the National Organization for Marriage, the Family Research Council, and the American Family Association conducted a $1 million campaign to remove the three judges.

Ternus, Streit and Baker were part of a seven-judge panel which ruled in favour of gay marriage last year but were the only three up for the vote.

In a statement, they blamed “special interest groups” for their defeat.

They said: “We also want to acknowledge and thank all the Iowans, from across the political spectrum and from different walks of life, who worked tirelessly over the past few months to defend Iowa’s high-caliber court system against an unprecedented attack by out-of-state special interest groups.”

The campaign against them was led by Bob Vander Plaats of Iowa for Freedom, who accused them of “radical judicial activism”.

The Human Rights Campaign said that the campaign was “about sending a warning shot to judges nationwide”.

Group president Joe Solmonese said: “[National Organization for Marriage] and its secret donors will continue to target judges around the country if they rule in favor of marriage equality and will foster an anti-gay, hostile environment in the process.”

This year is the first year since the 1990s that there has not been a state proposition to ban same-sex marriage.