The election was closely watched, coming ahead of next year’s congressional and presidential elections. The Democrats in Wisconsin, fueled by millions of dollars in spending by national unions and other outside groups, still managed to pick up two seats Tuesday while four Republicans staved off attempts to recall them from office.

The six Republican state senators faced a recall vote after siding with the Republican governor on a law that took collective bargaining rights away from state workers.

The vote is seen as a test of the power of small-government, anti-tax Republicans who won control of the US House of Representatives last year. Wisconsin is also a potentially important swing state that could help determine whether President Barack Obama is re-elected.

The recall election — aimed at unseating legislators — was called because Democrats are livid that Republican Gov. Scott Walker and his party backers adopted legislation earlier this year that strips most public workers of rights to bargain on labor contracts.

The legislative fight over his plan attracted national attention — and tens of thousands of protesters to the Wisconsin Capitol.

The battle isn’t over yet. Two Democratic incumbents face recalls next week. A third Democrat survived a recall attempt last month.

Billions of dollars have poured into the state from unions as well as political parties. More than $31 million was estimated to have been spent on the nine recall elections, rivaling the $37 million spent on last year’s governor’s race.

Republicans won control of both houses of the Legislature and the governor’s office in the 2010 election just nine months ago, and how the recall election goes could signal whether they can hold those majorities.

Both parties also were testing their messages ahead of the 2012 presidential race, in which Wisconsin could be an important swing state.

Turnout was strong in the morning and steady in the afternoon in communities like Whitefish Bay, Menomonee Falls and Shorewood, where Sen. Alberta Darling was one of six Republicans trying to keep her seat.

Republicans hold a 19-14 advantage in the Senate, so Democrats need to win five of the eight elections to take control.

If Republicans lose three or four seats on Tuesday, the balance of power in the Senate will rest on the outcome of the two Democratic races next week.

The stakes were clearly much larger than simply determining who has control of the state Senate — the elections figured to help determine whether the Republican revolution led by Walker will get a shot in the arm or a major setback. Both parties also were testing messages ahead of the 2012 presidential race, in which Wisconsin was expected to be an important swing state.

Republican and Democratic strategists were leery of reading too much into the results heading into next year’s campaign.

The recall effort helped stir passions in the Democratic base “in ways we might never have been able to achieve on our own,” said Roy Temple, a Democratic political consultant with extensive experience in the Midwest. But, he said, that doesn’t mean the recall can offer much more than hints about broader trends.

Republican National Committee Chairman Reince Priebus said it was “all in” to win the races, while a coalition of national unions spent millions on attack ads and other campaign activity to take seats from the Republicans. Conservative groups also spent millions.

Since January, the Legislature that had been passing Republican-backed bills in rapid succession and with great ease will likely grind to a halt if Democrats win back the Senate and are then able to block anything from clearing without a bipartisan agreement.