Sen. Ted Cruz (R-Tex.). (Christopher Millette/Erie Times-News via Associated Press)

When Ted Cruz attacked “New York values” during his successful campaign against Donald Trump for Iowa’s caucuses, he knew exactly what he was doing. New York — the place, its people, its outsize role in American culture and, yes, its values — has long played badly in the Republican heartland.

Cruz boasted about the effect of his anti-Gotham sally the night he won Iowa. “As I travel the country here in Iowa, New Hampshire, South Carolina, Nevada, everyone knows what New York values are,” he told ABC News’s Jonathan Karl shortly after delivering his Iowa victory speech.

A dislike of New York in the GOP is nothing new. In his fine book about the three-term New York governor and two-time Republican presidential nominee, “Thomas E. Dewey and his Times,” Richard Norton Smith noted that Sen. Robert A. Taft of Ohio, the party’s conservative hero during the Roosevelt-Truman era, had seen his presidential hopes “ground up in the relentless machinery of the Eastern Establishment, those New York liberals who prefer victory to ideological purity and to achieve it are willing to accept the New Deal.”

Taft and his loyalists felt about the Big Apple the way Red Sox fans feel about the Yankees. Smith wrote, “New York newspapers, New York banks, New York arrogance — the very city Taft’s America loves to hate — all have become synonymous in Old Guard eyes with the man one Taft partisan calls ‘that snooty little Governor of New York.’ ”

But by going after Trump’s home state, Cruz handed Trump a political promissory note that will be cashed in Tuesday in New York’s primary. No matter how much Cruz tried to refine and limit his attack (he insisted he was going after Manhattan and liberal politicians, not the New York firefighters and cops beloved around the nation since Sept. 11, 2001), New Yorkers knew he had targeted them. There was no coming back for Cruz, and the main question for the day is not whether Trump will win the state in a landslide — that seems all but guaranteed — but whether Cruz runs third, behind Ohio Gov. John Kasich.

As you watch the returns Tuesday night, however, remember that Trump’s New York Republicans are not Dewey’s GOP. New York was, as Smith observed, once home to some of the most liberal Republicans in the nation, including Sen. Jacob Javits, Gov. Nelson Rockefeller and New York City Mayor John V. Lindsay.

Over the years, the state party became much more conservative, much more like the Republicans in the old Taft country. Running for reelection in 1969, Lindsay was beaten in a Republican primary, won as a third-party candidate and later became a Democrat. Javits lost a Republican primary in 1980. And Rockefeller, picked by President Gerald Ford to be his vice president after Ford succeeded Richard Nixon in the wake of the Watergate scandal, was forced off the Republican ticket in 1976 by conservatives.

Cruz, in other words, forgot that there are conservative New York values, too.

On the Democratic side, Hillary Clinton is heavily favored, and one of the things to watch is how well she does against Bernie Sanders in upstate New York, most of which resembles the Midwest far more than New York City. If Sanders makes the contest at all close, upstate will be the key. Look at the returns from the 31 upstate counties that insurgent Zephyr Teachout carried in her unsuccessful but surprisingly strong 2014 Democratic primary challenge to Gov. Andrew Cuomo. (Teachout is running for Congress this year.)

But if Clinton wins going away, her victory will, in part, reflect the years of work she has put in upstate since she decided to seek a New York U.S. Senate seat in 2000. As Michael Tomasky noted in his excellent account of that race, “Hillary’s Turn,” both Clinton and Sen. Charles Schumer (elected in 1998) understood that upstate’s economic troubles — the very forces Sanders is counting on — had made the vast region more hospitable to Democrats. Clinton developed an affinity for the parts of the state that had more in common with her native Illinois than with Brooklyn and the Bronx.

A Clinton win, especially a big one, would be decisive in her campaign against Sanders. It is hard, barring a miracle (or, from Clinton’s point of view, a disaster), to see how Sanders can win the nomination if he loses Tuesday.

On the Republican side, it’s true that once the campaign leaves New York, Cruz can go right back to bashing New York values. Doing so might help him in Indiana, the next big battleground, on May 3. Trump is still a long way from securing the nomination.

But by reprising Taft’s anti-New-York state of mind, Cruz threw away his chance to be at least moderately competitive in the state. If Cruz is crushed Tuesday and ultimately loses the Republican nomination, we might well look back on his trashing of New York values as one of the key reasons for his defeat.

The good people of the state, even the ones who loathe Trump, could chuckle knowingly: Revenge on those who turn against them is, sometimes at least, a New York value.