“We wish to thank all of the Iowans who voted to retain us for another term,” the judges said in a statement. “Your support shows that many Iowans value fair and impartial courts. 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.

“Finally, we hope Iowans will continue to support Iowa’s merit selection system for appointing judges. This system helps ensure that judges base their decisions on the law and the Constitution and nothing else. Ultimately, however, the preservation of our state’s fair and impartial courts will require more than the integrity and fortitude of individual judges, it will require the steadfast support of the people.”

Though several groups formed to support their retention, they were significantly outspent by the organizations that bankrolled the ouster effort, including the National Organization for Marriage and the American Family Association.

“We’re concerned about the precedent this has set tonight and what it means for the influence of money and politics on the judicial system,” said Dan Moore, co-chair of Fair Courts for Us, which supported the judges.

The judicial races were perhaps the most hotly anticipated item on the ballot this year, a sharp contrast from years past in which the election were so low profile that more than a third of those who cast ballots left the section blank. “That’s the main reason I came out,” said Michelle Kramer, 36, a college student from Des Moines. “People can do what they want to do, they can love who they want to love.”

Her friend and neighbor Cathy Hackett, 38, took the opposite view. “I voted no for every single one of them,” said Ms. Hackett, a customer sales representative who described herself as a conservative Christian. “I’m not anti-gay. I love everybody. But I believe that if two people are going to marry they should be a man and a woman.”

The outcome will have no effect on the ruling that triggered the campaign, a 7-to-0 decision that found that a law defining marriage as between a man and a woman represented unlawful discrimination under the state constitution.