President Barack Obama answers a question during a news conference in the East Room of the White House, Wednesday, Nov. 5, 2014, in Washington. (AP Photo/Jacquelyn Martin) (Jacquelyn Martin/AP)

Back in July, when President Obama was deciding whether to take executive action on immigration before the midterm elections, I got into one of those cable-news debates that offer the president unsolicited advice from the unqualified.

I argued that the move would boost Hispanic turnout and rally a depressed Democratic base. Yes, it might hurt some vulnerable Democratic candidates, but it would cement Hispanic loyalty to the party in the long run: “It’s a question of, whose interest is he looking out for?”

My opposite, Bloomberg News’s Mark Halperin, countered against “inflaming” the Republican base. “There’s almost no competitive races where the Hispanic vote is going to be decisive,” he argued, and “there are a lot of Democratic strategists who say, ‘This will hurt our chances in the midterms. Why not wait until November to do it?’ ”

“So,” asked the host, “why are they even considering it?”

Replied Halperin: “My sources and I, we can’t figure it out.”

Maybe they can now.

The president declined to act on immigration before the election. But all the Democratic Senate incumbents in red states that he was trying to protect lost anyway on Tuesday. There is evidence that the combination of low Hispanic turnout and lower Hispanic margins for Democrats doomed some Democratic candidates, including Charlie Crist, who lost his gubernatorial race in Florida, and perhaps Sen. Mark Udall, who lost his reelection bid in Colorado.

Worse, the fading ardor Latinos showed for Democrats raises the possibility that this reliable constituency — crucial to the party’s prospects in 2016 and beyond — is slipping away. Now Obama, to avoid even more trouble with Latinos, has vowed to take unilateral action on immigration by year’s end, even though GOP leaders say that will “poison the well” with the congressional majority. As the NBC News political team speculated: “Given the current situation, we think the White House wishes it went ahead and issued that executive action back in the summer.”

There is a lesson here that goes beyond immigration: Obama would have been better off doing what he thought was right and letting the politics take care of themselves. When Halperin, co-author of the bestseller “Game Change,” and Democratic strategists called for postponing executive action, they were looking at politics as a game, moving pieces to maximize numbers after the next election. But politics is not just always a game of winning the next election. It’s about doing, as Obama belatedly remembered Wednesday, “what I think is best for the country.”

Instead, his political calculation turned out to be too clever by half, and he wound up setting back a worthy cause without helping Democrats at the polls. “You repress the vote in the Latino community, and what did you come up with?” Rep. Luis Gutierrez (D-Ill.) asked rhetorically during a news conference in Chicago on Wednesday, according to an account in Politico. He called the loss an “indication about what happens when you try to toy with your principles and your beliefs.”

In Florida, the Hispanic share of voters dropped to 13 percent from 17 percent two years ago. Because Latinos favored Crist over Republican Gov. Rick Scott by 20 percentage points, that was likely enough to cost Crist victory in a close race.

In Colorado, where Republican Sen.-elect Cory Gardner made a big play for Latino votes and Udall did little until the last minute, a Wall Street Journal analysis found that of the 21 counties in the state where Hispanics are at least one-fifth of the electorate, Gardner did better than the 2010 Republican Senate nominee in 20 of them. In 2010, Latino voters were credited with Democratic Sen. Michael Bennet’s narrow win in the state.

Hispanic turnout slipped to 8 percent of the electorate from 10 percent in 2012 and level with 2010, despite the exploding Latino population. Democrats got 62 percent of the Hispanic vote, better than a dreadful 2010 showing but well below the 71 percent Obama got in 2012. In the Texas governor’s race, Republican Greg Abbott got 44 percent of the Hispanic vote, and in the Georgia governor’s race, Republican Nathan Deal got 47 percent. In Kansas, Republican Gov. Sam Brownback won the Latino vote, 47 percent to 46 percent, exit polls show.

This doesn’t necessarily mean Obama’s delayed action on immigration caused Democrats problems with Latinos, nor does it mean Tuesday’s results would have been dramatically different if he had acted sooner. But it does make a case for worrying more about what’s right than what’s expedient.

Twitter: @Milbank

Read more from Dana Milbank’s archive, follow him on Twitter or subscribe to his updates on Facebook.