Republicans managed to beat Heidi Heitkamp in North Dakota. But down the ballot, they paid a price for trying to block her Native American base from voting.

On Tuesday night in North Dakota, Democrats faced a stinging blow with the loss of Sen. Heidi Heitkamp.

A bipartisan problem-solver, Heitkamp did a lot in her time in the Senate — she expanded the Violence Against Women Act to cover Native American tribes, sponsored a bill to help farmers hurt by tariffs, and heroically stood up for women by voting against Brett Kavanaugh for the Supreme Court. She was unseated by GOP Rep. Kevin Cramer, a hard-right ideologue who has suggested attempted rape isn't a crime. The loss was broadly expected, as she was badly trailing in polls for weeks.

But further down the ballot, North Dakota Republicans paid a steep price for the lengths they went to to defeat her.

Shortly after Heitkamp first won her seat in 2012, carried to a narrow victory by Native American voters, GOP lawmakers in North Dakota retaliated by passing a voter ID bill making it almost impossible for Native Americans on tribal lands to vote. The law required them to use an ID card bearing a residential street address — even though most people in tribal communities do not have a street address. The law was initially blocked by a federal judge, but allowed to take effect on appeal.

But North Dakota Republicans didn't anticipate what a massive backlash there would be to their skullduggery. Immediately after the Supreme Court let the law take effect, furious Democratic activists all over the country crowdfunded a massive effort to get street addresses and updated ID cards for Native Americans in the state.

The effort was so successful that on Election Day, Native turnout was actually higher than 2012 in several places. The high turnout was not enough to save Heitkamp, as the state's electorate has shifted significantly right of where it was six years ago — but at the legislative level, angry Native voters flipped at least three red seats blue, including state House Majority Leader Al Carlson.

In the most poetic justice of the night, Randy Boehning, a GOP state representative in Fargo who sponsored the Native American disenfranchisement law in the first place, was unseated by Democrat Ruth Anna Buffalo — a Native American.

It is hard to call the midterm results in North Dakota a positive thing for Democrats. But even though they lost the Senate race, they can take satisfaction in knowing that the Republican law passed to deny Native Americans the vote was an utter failure that woke a sleeping giant — and may have done the GOP more harm than good.