DES MOINES, Iowa (AP) — The Republican-led House voted Monday to reject 29 absentee mail ballots cast in a northeast Iowa House district, handing the seat to a Republican who won by nine votes in the first contested election to go before the Legislature in 27 years.

The mailed absentee ballots were confirmed by a U.S. Postal Service scan of a barcode on the envelopes as having been sent to election officials on time, but House Republicans insist those barcodes are not allowed under state law to be used to validate ballots.

Iowa law says mailed absentee ballots must be postmarked to confirm they were mailed by the deadline one day before an election. The 29 ballots had no postmark.

Legislators, realizing mail ballots often are no longer postmarked, updated the law in 2016 to allow a specific code called an intelligent mail barcode to be used to authenticate ballot timeliness if a postmark is missing. The Postal Service has acknowledged absentee ballots are not always postmarked.

About 1,045 absentee ballots received by mail were rejected in the November election because they were not postmarked or were received too late, Iowa Secretary of State Paul Pate’s office said in response to a Freedom of Information Act request from The Associated Press.

House Republicans argued a postal routing barcode is not an intelligent mail barcode as defined in Iowa law and cannot be used to validate ballots, and therefore the 29 votes must be rejected.

“This isn’t comfortable. This isn’t pleasant and we don’t change the rules in the middle of the contest. That’s why we have to follow the rule of law in this case,” said GOP Rep. Steve Holt of Denison.

Incumbent Republican Rep. Michael Bergan won by just nine votes out of more than 14,000 votes cast on Nov. 6. Counting the 29 votes from Winneshiek County could have changed the outcome of the race.

Democrat Kayla Koether filed an election challenge, which by law means the House had to decide whether the ballots are opened and counted. It’s the first contested election to be decided by the Legislature since 1992.

Koether said lawmakers have the authority to interpret the law in a way that allows them to count the ballots of voters who did everything right.

“They are making a choice here about how to interpret the law and whether they will do so in a way that includes these 29 voters who want their votes to be counted or not,” she said. “They can follow the rule of law and count these ballots.”

The House voted 53-44 along party lines to reject the ballots and dismiss Koether’s challenge. Democrat Bruce Hunter said democracy suffers when legitimate votes are denied.

“It seems nobody will ever deprive the people of Iowa the right to vote except the Iowa Legislature. For 29 people in Winneshiek County, democracy is dead,” Hunter said.

Koether said she and some of the voters may file a lawsuit.

Her attorney has said the inconsistent way of affirming votes in Iowa may present a constitutional equal protection challenge. Another county in the same House district, Fayette County, counted 12 ballots with no postmark or barcode. The county election official has acknowledged that was a mistake.