Updated

DENVER -- Sen. Michael Bennet narrowly defeated tea party Republican Ken Buck on Wednesday, allowing Democrats to hold onto a Senate seat once viewed a prime opportunity for the GOP to make gains.

Bennet provided a crucial firewall against further Republican gains in the Senate during midterm elections in which the GOP made a historic surge. Many polls showed that Buck had a small lead heading into the election.

The race attracted more out-of-state campaign money than any other Senate contest this year, prompting a stream of vicious attack ads as both parties viewed the race as the one that could tip the balance of power in Congress.

"This is definitely a race for the record books," Bennet said in a victory speech outside the Denver museum where President Barack Obama last year signed the stimulus bill into law.

Bennet urged sharply divided Colorado voters and politicians to "set aside our petty differences and make sure this state and this country lead in the 21st century." And he congratulated Buck, saying, "I honor his commitment to public service."

With 97 percent of the projected vote counted, Bennet was leading by about 15,400 votes out of 1.4 million cast.

Buck didn't immediately concede the race.

"We are still looking where returns need to be reported, as well as provisional ballots before making any decisions," Buck said in a post on his Facebook page.

Bennet, 45, was appointed to the seat last year to replace Ken Salazar, who became Interior Secretary. Before his appointment, Bennet was superintendent of Denver Public Schools and had never run for public office.

Democrats retained control of the Senate on Tuesday, though they lost at least six seats to the GOP. Senate races in Washington and Alaska were too close to call Wednesday.

With the Senate victory, Democrats were able to beat back strong GOP challenges in the midterms. Democrat John Hickenlooper won the governor's race, although Republicans picked up two House seats in the state.

During the Colorado campaign, Bennet painted Buck as too conservative, especially on social issues. Buck opposes abortion rights, even in cases of rape and incest, and considers sexual orientation a choice.

Bennet and the Democrats pounded Buck with attack ads calling him "too extreme for Colorado."

Buck sought to portray Bennet as part of the problem in Washington as the federal government carries out reckless spending.

Among the heavy-hitters coming to Buck's assistance was American Crossroads, a conservative group affiliated with Republican strategist Karl Rove that spent millions on ads attacking Bennet.