It was exhilarating — that night in July 2004, when a young Senate candidate from Illinois stood before a national television audience, invoked his improbable Kenyan-Kansan background, and called upon Americans to unite.

There’s not a liberal America and a conservative America,” Barack Obama said. “There’s the United States of America. . . . We worship an awesome God in the blue states, and we don’t like federal agents poking around in our libraries in the red states. We coach Little League in the blue states and, yes, we’ve got some gay friends in the red states. . . . We are one people, all of us pledging allegiance to the Stars and Stripes, all of us defending the United States of America.”

Those powerful words, and the powerful hope they expressed, helped propel Obama to the presidency and, ultimately, to his bitter reelection struggle against Mitt Romney.

In 2012, though, his language, and that of his Democratic surrogates, is different: “Romnesia,” “Romney bet against America” and, in one television ad, “Mitt Romney — he’s not one of us.”

In 2004, Obama denounced “those who are preparing to divide us — the spin masters, the negative ad peddlers who embrace the politics of ‘anything goes.’ ” In this campaign, some of those people work for him.

What went wrong?

It’s not, as his worst detractors on the right would have it, that Barack Obama is some kind of unusually sinister politician, who revealed his true nature after taking office. Nor is it sufficient to protest, as Obama’s supporters do, that he had to respond in kind when faced with unprecedented GOP demonization.

The problem is simpler: Obama’s 2004 speech, though undoubtedly sincere, was not true. Americans were deeply divided then, and they are, if anything, more deeply divided now.

Polarization has reached the point where party affiliation predicts a person’s beliefs better than race, education, income, religiosity or gender, according to a remarkable study published in June by the Pew Research Center. More ominous, to anyone familiar with the political history of 19th-century America, is that party and ideology overlap heavily with geography.

Divergent social systems, founded in divergent value systems, are taking root in different regions. Are there really no red states and no blue states? Only if you think it’s an accident that public-sector unionism is weakest below the Mason-Dixon line, or that almost all of the states that allow same-sex marriage are in the Northeast.

Meanwhile, pundits and politicians spend far more energy on mockery and hatred than on mutual comprehension.

This is why Obama is now the second president in a row to win election as a uniter — and then campaign for reelection by trashing his opponent and herding his party’s base to the polls.

No doubt the president would reject this comparison with George W. Bush. But I mean it as a statement of reality, not an accusation. This is just the way presidential politics works in a polarized milieu. And for all his charisma and good intentions, Obama could not transform that dynamic, or even resist it.

As if conceding the point, Obama offers 2012 voters not hope but “a choice between two fundamentally different visions for America.” Romney, too, paints his disagreements with the president in stark terms — leavened, of late, by pledges of bipartisan cooperation faintly reminiscent of those that helped Bush and Obama win, but no more plausible.

Both men promise the party faithful that electoral victory will mean policy triumph; if recent history has shown anything, though, it is that neither party is strong enough to impose its agenda. Nor is there much to be gained from conventional legislative compromise. The country’s financial problems are too great for piecemeal solutions, and the parties’ differences on how to solve them are too big to split.

Our predicament calls for a different kind of politics — in the tradition of the sectional Great Compromises of pre-Civil War America, including the deals embodied in the Constitution itself.

In those grand bargains, seemingly irreconcilable factions stopped trying to crush each other, at least for a time, and exchanged concessions on principle for the greater good of political stability. It was the domestic equivalent of land for peace.

Though they preserved the Union for decades, the Compromises were fatally tainted by slavery and thus could not ultimately stave off national breakdown.

Prospects for durable compromise today are accordingly brighter — assuming the winners in Tuesday’s elections learn from the past 12 years’ worth of partisan uniting and dividing.