Ever since 2016, when Donald Trump defeated Hillary Clinton despite earning almost three million fewer votes nationwide, many Democrats have set their sights on eliminating the Electoral College.

In a surprise move last month, however, 21 Democratic members of the Maine House of Representatives joined their Republican colleagues in voting to preserve our time-honored system for electing the president.

The Maine legislators had been considering whether to join an interstate compact that would have required the state to give all of its electoral votes to the winner of the nationwide popular vote.

Admittedly, the idea that the person who garners the most votes should win the presidential election has surface appeal. But the compact — which 15 jurisdictions, including Massachusetts, have already joined — is probably unconstitutional. (The US Constitution establishes the procedures for presidential elections, and it is unlikely that the Supreme Court would approve a backdoor attempt to change the rules without a constitutional amendment.)

Constitutional defects aside, the compact would undermine democracy within each state. Had the law been in effect in 2004, for example, Maine would have been required to give its electoral votes to George W. Bush, even though the majority of Mainers voted for John Kerry.

The whole point of the Electoral College, of course, is to give less populous areas of the country, like Maine, a voice in presidential politics. The Electoral College forces each candidate to cobble together an electoral majority from diverse parts of the country. This creates an incentive for candidates to appeal to voters outside of their regional or ideological base and to consider the will of the people in each state — not just in the most populous metropolitan areas.

Under this system, Maine, with only 1.3 million people, received three visits from presidential candidates in 2016. With a simple nationwide popular vote, no candidate would waste time in Maine. Presidential candidates would simply set up shop in New York and Los Angeles and other major media markets and forget that Maine even exists.

Maine’s voice may not always carry the day in the Electoral College, but at least Maine has a chance to be heard.

The day after the Maine House rejected the popular vote compact, Nevada’s governor, Steve Sisolak, a Democrat, vetoed a similar bill. In a letter to the speaker of the Nevada Assembly, Sisolak wrote that joining the compact “could leave a sparsely populated Western state like Nevada with a greatly diminished voice in the outcome of national electoral contests.” He’s right.

But while a nationwide popular vote would surely be unfair to Maine and Nevada, what of those occasions when the winner of the Electoral College earns fewer votes nationwide than his or her opponent? Isn’t that unfair to the whole country?

The truth is, such Electoral College “upsets” are rare — in fact, they have occurred only five times in our nation’s history. But even in those cases, the system has worked as intended, with the winning candidates earning support from a broader cross-section of voters than their opponents. Far from being undemocratic, this feature of our electoral system is actually democracy-enhancing, as it ensures that a diversity of voices are heard.

Last month, the Maine House prevented the state from committing political suicide — for now. But the Maine Senate, which passed the bill the first time around, may yet push the measure through.

Democrats upset with the outcome of the 2016 presidential election would be better off focusing on winning back Rust Belt voters who abandoned their party for Trump, rather than writing off these voters and changing the rules of the game.