MADISON, Wis. - After two years of heart-wrenching defeats, capped by Republican Gov. Scott Walker's recall victory this summer, Wisconsin Democrats were on an unrelenting losing streak.

And when popular former Gov. Tommy Thompson decided to run for U.S. Senate, Republicans appeared poised for yet another prominent win that would give them control of both Wisconsin's Senate seats for the first time since the 1950s.

But there would be no GOP sweep.

President Barack Obama fired up his turnout machine and made winning Wisconsin a priority, pouring star power and money into the state. And fellow Democrat Tammy Baldwin, a liberal congresswoman who had never run in a statewide election, put together a well-funded, disciplined and smart campaign in the face of long odds against an opponent so well-known that most people simply call him "Tommy."

It paid off: Both Obama and Baldwin won their tight races Tuesday, keeping alive Wisconsin's tradition as a state that doesn't stay all blue or all red for too long.

The victories were the biggest scores for Democrats since Obama's surprising 14-point win in Wisconsin in 2008 that left Republicans sullen and confused. The GOP found itself in a similar position Tuesday night.

"We're all quite stunned at the results because we had such an energized base, the independents were falling our way," Republican state Sen. Alberta Darling, co-chair of Mitt Romney's Wisconsin campaign. "People were coming out of the woodwork to help. Maybe we were just not dealing with the real reality."

Republicans did, however, regain control of the state Senate and maintained their majority in the Assembly — once again giving the GOP full control of state government. Still, the Obama and Baldwin victories were significant for Democrats who were downtrodden just five months ago when Walker survived the recall, said Wisconsin Democratic Party Chairman Mike Tate.

"We were never as blue as we looked in `08, we were never as red as we looked in `10," Tate said in an interview. "It's a narrowly divided state."

With her win, Baldwin will become the first female U.S. senator from Wisconsin and the first openly gay candidate to win election to the Senate. Her victory also handed the 70-year-old Thompson his first loss in a statewide election and likely spells the end of his storied political career.

Republicans were searching for a silver lining in the national losses, and they found it with the GOP winning back the state Senate. That returned state government to where it was before a Republican loss in a recall election in June gave Democrats a narrow one-vote majority in the Senate, though that Democratic majority was largely symbolic since the legislative session doesn't begin until January.

Republicans also held on to control of the state Assembly.

"We must look at the wonderful job our great governor Scott Walker has done for us, and the people in the state of Wisconsin were wise enough to return to him a majority in our state Senate," Attorney General J.B. Van Hollen told dejected Thompson backers at what supporters had hoped would be a victory party.

What Republicans do with their reclaimed majority remains to be seen. Legislative leaders and Walker have been vague in describing their agenda for the next two years.

There was no change to the makeup of the state's U.S. House delegation. Five Republican incumbents, including Romney running mate Paul Ryan, and Democrats won re-election. State Rep. Mark Pocan, a Democrat, won the race to replace Baldwin in her Madison-area congressional district.

Wisconsin's gay community heralded the wins of both Baldwin and Pocan, who also is openly gay.

"This is truly a historic night for the lesbian, gay, bisexual and transgender community," said Katie Belanger, executive director of Fair Wisconsin, the state's largest gay rights group.

Republicans were also buoyed by Ryan's ascendance after being picked as Romney's running mate, even though it ultimately was a losing effort. The longtime congressman is already being discussed as a possible presidential candidate in 2016.

About half of those surveyed in an Associated Press exit poll said they had a favorable opinion of Ryan, including one in eight who said they voted for Obama. Four in 10 said they had an unfavorable view of Ryan.

Tuesday's election caps off a wild two years in Wisconsin, first with the fight over Walker's collective bargaining law, then the multiple recall elections targeting state senators and Walker, followed by Ryan's rise and the state's central role in the presidential campaign.

While Republicans scored the most significant victories during the past two years, Democrats savored the reversal of fortunes brought by their wins Tuesday.

"It has been a tumultuous two years in Wisconsin as we have engaged in this great conversation over the future and values of our middle class," Tate, the Democratic Party chairman, said in a statement. "We know and feel deeply that change can be difficult — but as Senator-elect Baldwin's and the president's victory tonight proves — it will come."

___

Follow Scott Bauer on Twitter at http://twitter.com/sbauerAP.