President Barack Obama and Congressional Republicans are proving they can work together under threat of impending crisis — and to pass out expensive goodies to the electorate.

Next year, the question will be: Can they agree when crises are less imminent and when the solutions may involve taking benefits away?

Obama, attacked by the far right as a “socialist,” is proving to be a pragmatist if not a centrist. But will Republicans respond constructively and negotiate with him?

Ideally — and this is what poll after poll shows that the public wants — the 2012 election could be fought over who deserves the most credit for solving America’s problems, not who’s to blame for not solving them.

The bipartisan tax deal passed by the Senate on Wednesday was a beginning, but it was hatched under intense pressure: If it’s not adopted, everyone’s taxes will go up Jan. 1, crippling a weak economic recovery, and 2 million jobless workers will lose unemployment benefits at Christmastime.

So Obama agreed to items he detests — extension of income and estate tax breaks for the wealthy — in order to secure unemployment benefits, a one-year payroll tax holiday for workers and various other tax credits.

And Republicans accepted Obama’s tax breaks in return for extension of the George W. Bush tax cuts for those making more than $250,000 and inheritance tax breaks for the very rich.

Polls show that the public didn’t like elements of the package — including, strangely, the cut in payroll taxes — but cheered the whole.

According to the latest Washington Post/ABC poll, 69 percent supported the deal, and 62 percent said they did so even after being informed that it could increase the federal deficit by $900 billion over 10 years.

Among politicians, the deal won overwhelming approval, too, except among deficit hawks and on the right and left fringes.

Republicans opposed were mainly on the far right: Rush Limbaugh, various tea party activists, the Club for Growth, Rep. Michele Bachmann (Minn.), Sen. Jim DeMint (S.C.) and former Alaska Gov. Sarah Palin.

So was former Massachusetts Gov. Mitt Romney — in what was widely interpreted as an attempt to curry favor with the right, where he’s under suspicion for once promoting Obama-style health care reform.

According to a Battleground poll last year — the most recent to ask the question — only 19 percent of voters self-identified as “very conservative” (vs. 40 percent “somewhat conservative”), and a more recent McClatchy/Marist poll indicated that just 29 percent supports the tea party.

Yet that minority and its mouthpieces have disproportionate sway on Republicans and could well try to block future compromises by Republicans with Obama — assuming they can be reached.

Meanwhile, on the Democratic side, ideology is even more rampant in spite of the fact that perceived excessive liberalism was largely responsible for the party’s getting whacked in the 2010 elections.

Democratic Congressional leaders had all year to pass a tax bill or try to embarrass Republicans with votes favoring millionaires, but they waited until after the election to act, putting Obama in a weak bargaining position.

Even then, the deal he worked out arguably favored Democrats. A Washington Post analysis showed that Obama-sought items in the package amounted to $343 billion, compared with $103 billion for GOP items and $500 for mutually agreed-upon items.

But the deal was denounced as “capitulation” by liberal Members of Congress and as “kowtowing” and “triangulation” (a dirty word to liberals) by left commentators.

Most polls indicate that only about 20 percent of Americans self-identify as liberal. The Battleground poll last year showed that 10 percent consider themselves “very liberal” and 26 percent “somewhat liberal.”

The left’s outrage — and Democratic Congressional resistance — was all the more irrational given that next year Republicans will be in a much stronger position to write tax laws their way.

Obama is showing that he, at least, got the message of the 2010 elections. He met Wednesday with big-business leaders he’d previously bashed. He closed a trade deal with South Korea. His idea of economic stimulus is heavily weighted toward tax cuts, albeit temporary ones.

And, he is signaling that he is ready to start working next year on deficit reduction and tax reform. If achieved, that would do much to undo the damage of this week’s $900 billion tax deal and save the country from long-term fiscal disaster.

But that requires bipartisan cooperation to do unpleasant things — cut spending, reduce the growth rate of entitlement benefits, cap or take away tax breaks and raise revenue.

The Washington Post poll showed that the public favors debt reduction by a combination of spending cuts and tax increases but opposes most specific items in both categories.

The Post poll indicated that the public thinks Obama is more willing to compromise than Republicans are — and that it’s less enamored of GOP ideas than it has been after other big election victories.

So, just imagine a 2012 election in which Democrats and Republicans competed over who deserved the most credit for defusing the debt bomb, for reforming the tax system, for improving education — instead of battling over who’s to blame for deadlock. It’s a dream, I know.