Associated Press
President Barack Obama gestures while giving his State of the Union address on Capitol Hill in Washington, Tuesday, Jan. 24, 2012.

The Republican presidential race proves that Karl Marx was right: When history repeats itself, it occurs first as tragedy and then as farce. Fortunately, both can be instructive.

For the tragedy, you have to go back to 1948, when a superb public servant named Thomas E. Dewey lost a presidential election to a machine politician by the name of Harry S. Truman, who happened to be the never-say-die incumbent.

A man of unimpeachable integrity, Dewey was a fearless prosecutor who battled the mob and later, as New York's governor, helped establish the state university system and the Thruway, which is named for him. Dewey had his shortcomings, of course. Given his small size, stiff back and prim mustache, he was easy prey for wags. Alice Roosevelt Longworth, Theodore's daughter, went around saying he looked like "the little man on the wedding cake." (Longworth owned a cushion that said, "If you have nothing good to say about anybody, come sit by me.")

Fast forward to the current campaign, in which it's hard to avoid noticing how much Mitt Romney has in common with Dewey. They're both originally from Michigan. Both obtained Ivy League law degrees. And both fostered social change as governors of important Northeastern states. In Massachusetts, Romney signed a universal health care plan. In New York, Dewey signed a bill — among the first of its kind — banning religious and racial discrimination in employment.

Like Dewey, Romney is an intelligent, capable and, most of all, moderate Republican. Both have in common a desire to be president, one supported by Wall Street and party elders. Also like Dewey, Romney doesn't seem to inspire much love among voters nationally. And like Dewey, he must cope with an incumbent Democrat who will run as a populist.

Romney also faces a strong challenge from the right within his own party — just as Dewey did. The challenge to Dewey came from Ohio Sen. Robert Taft, who embodied the conservative movement in his party as much as Dewey exemplified the more liberal strain. The GOP has oscillated between these poles ever since, lurching between Barry Goldwater, Ronald Reagan and George W. Bush on the right, and Richard Nixon and George H.W. Bush on the left.

Now the battle is between Romney and Newt Gingrich. Unfortunately, that's where the analogy ends. In their day, Dewey and Taft were political giants. Dewey was easy to mock, but he had the courage to oppose McCarthyism. Taft, who opposed big government and foreign entanglements, also opposed Prohibition and the Ku Klux Klan.

With his flip-flopping, Romney is no Tom Dewey. Taft, meanwhile, revered the institution of the Senate. But Gingrich, when he was speaker, played a big role in fostering the partisan and fact-averse climate now afflicting the House.

Politics has changed a lot since 1948. Back then, candidates were chosen by party leaders at a national convention focused on electability. The GOP pros who met in 1948 never would have picked Gingrich. They passed over Taft for candidates they considered likelier to win in November. But nowadays, the voters pick the candidates in primaries that magnify the power of ideological purists. And no matter how hard Romney tries to disguise it, he's a moderate northeastern Republican, a species all but extinct since the day of Jacob Javits and Nelson Rockefeller. That means Gingrich may knock him off in the unfolding primary fight.

It wasn't much of a tragedy that Truman beat Dewey. But in facing Barack Obama this fall, Republicans may yet discover that the triumph of Gingrich over Romney, if it occurs, qualified as farce.

Daniel Akst, a columnist for Newsday, is the author of "We Have Met the Enemy: Self-Control in an Age of Excess" from Penguin Press.