White House aides announced Tuesday night that President Obama was not watching off-year election results on television.

Actually, the president should have been watching.

Indeed, he should have stayed up late.

Tuesday night started lousy for Obama and the Democrats.

Republicans quickly won all three statewide races in Virginia, scoring an off-year election sweep that restored GOP dominance in a state where years of Democratic advances culminated in Barack Obama’s 2008 victory in the state.

Then the GOP snatched the governorship of New Jersey, a state where Obama had put his prestige on the line in an effort to secure a second term for Governor Jon Corzine.

Only late in the evening — after a brief moment when it looked as if New York Mayor Mike Bloomberg might lose to underfunded Democrat Bill Thompson (the independent incumbent finally prevailed by a 50-46 margin) — the news suddenly turned better for the Democrats.

Much better.

In the high-profile special election contest in upstate New York, Democrat Bill Owens won a U.S. House seat that had been held since 1872 by the Republicans. Owens maintained a steady 49-45 lead over Conservative Party nominee Bill Hoffman, who secured the support of the national GOP after Sarah Palin and other top Republicans rejected moderate Dede Scozzafava as the party’s nominee. (An embittered Scozzafava endorsed Democrat Hoffman but her name remained on the ballot and she pulled about 5 percent.)

The New York special election was portrayed as a critical internal test for a Republican Party that is battling to redefine itself in advance of the 2010 congressional elections. But it turned into a critical external test, and a fratricidal GOP failed it.

Then came the news that Democrat John Garamendi, who campaigned as an unapologetic backer of sweeping health-care reform, had won a big victory in the race to fill an open U.S. House seat in northern California. Garamendi, a rabble-rousing critic of big insurance companies who beat the choices of much of the party establishment in the primary, keeps a Democratic seat Democratic. But he will serve as a decidedly more progressive representative than the member he succeeds, Ellen Tauscher, who was one of the few California Democrats to join the conservative Blue Dog Caucus.

Tauscher took the seat in 1996 from a Republican and for many years the district was portrayed as one where only a conservative Democrat could beat the GOP. Garamendi’s win proves the thinking wrong and actually gives a boost to reformers in the House.

The federal wins came as a relief for Democrats who took hard hits in the gubernatorial contests.

Virginia Republican Bob McDonnell beat hapless Democrat Creigh Deeds by a 59-41 margin in a state Obama won by a comfortable margin in 2008. Republican won races for two other statewide posts, lieutenant governor and attorney general, by similar margins.

A smooth and effective candidate, he had won a statewide election four years ago (for attorney general in a race with Deeds) and ran a smart campaign that focused on the economy and job creation issues that are front-burner concerns in Virginia and most other states.

Deeds was a stumbling and ineffectual candidate who seemed at times to be doing his best to depress Democratic turnout — with the candidate going so far as to suggest that he would opt Virginia out of the public option if it was included in a health-care reform measure.

The Virginia results were a setback not just for Obama but for outgoing Virginia Governor Tim Kaine, who chairs the Democratic National Committee.

But the Virginia finish — which had been anticipated in the polls — was not as frustrating for Democrats as the New Jersey result.

Republican Chris Christie beat incumbent Democratic Governor Jon Corzine in the Garden State, where Obama swept in 2008 and to which the president returned again and again this year to campaign for Corzine.

Like Deeds in Virginia, Corzine brought liabilities to his race — he was so unpopular at the start of the 2009 cycle that Democrats talked of trying to replace him as their gubernatorial candidate.

To what extent were these races referendums on Obama?

While 55 percent of the voters in Virginia and 60 percent of the voters in New Jersey told exit pollsters they did not cast ballots with Obama in mind, substantial numbers of electors in each state indicated they they went to the polls with an eye toward sending the president a message.

In Virginia, 24 percent of those surveyed said they cast ballots with the intent of rebuking Obama, while just 18 percent said they were wanted to send the president a positive message.

In New Jersey, the divide was far closer — 19 percent positive on Obama, 20 percent negative.

The latter numbers may be somewhat reassuring to the White House.

But the real reassurance came in the congressional races.

While it is certainly possible to debate whether gubernatorial races are influenced by national trends and moods, there can be no such debate with regard to congressional contests — especially at a moment of bitter division in Washington.

Winning both special elections and actually increasing the Democratic majority in the House at such a moment is no small accomplishment. That does not mean that Obama and his allies should rest easy. They had a hard Tuesday. But, at least in the short term, what the president needs most is congressional support. And he got a little more of it Tuesday.

Obama and the Democrats also got the pleasure of knowing that, despite the gubernatorial wins in Virginia and New Jersey, Republicans will continue the battle for the soul of the GOP that erupted in New York’s 23rd district. The battle may well have cost the party a seat it had held since the days when Ulysses Grant occupied the Oval Office. And that defeat further eroded the minimal GOP presence in the northeast, a region where, remarkably, Democrats continue to expand their reach.

On a night when the “Tea Party” right was preparing to usher Hoffman into the House and solidify its control of the Grand Old Party, it instead helped add another Democrat to the Congress.