1 of 8
Brennan Linsley, Associated Press
Republican candidate for governor Bob Beauprez carries his granddaughter Katherine, age 5, as he talks to supporters during the GOP election night gathering at the Hyatt Regency Denver Tech Center, in Denver, Colo., on Election Day, Tuesday Nov. 4, 2014.

DENVER — Colorado Democratic Gov. John Hickenlooper has won a second term in office, narrowly defeating Republican challenger Bob Beauprez in a campaign that had the incumbent on the ropes amid criticism over the death penalty and gun-control legislation.

The contest was Hickenlooper's toughest of his career, and although he stumbled at times, his victory showed that he continues to be a political force in this state. His victory came in a big year for Republicans here and nationwide.

The race was much closer than anyone expected, and it was too close to call until Wednesday morning.

Hickenlooper survived more than a year of attacks over his decision to indefinitely halt the execution of convicted mass murderer Nathan Dunlap, who killed four people at a suburban Denver Chuck E. Cheese. Hickenlooper also weathered intense disapproval from Republicans over his party's wide-ranging 2013 legislative session that saw new gun control laws in response to mass shootings, civil unions for gay couples, and tuition benefits and driving privileges for people in the country illegally.

Beauprez hoped to become the first Republican to win the governor's office since 2002. But Hickenlooper had history on his side: The last time Colorado voters booted an incumbent governor from office was 1962.

Many political observers wrote off Beauprez after a 2006 gubernatorial bid in which he lost by 17 points. That year, Beauprez faced a Democratic wave with an unpopular Republican president in his sixth year. Hickenlooper found himself in the same unfavorable political circumstances this year.

Hickenlooper campaigned on his leadership during some of the state's worst natural disasters, with historic wildfires and flooding in 2013. He also oversaw an improving state economy that now has an unemployment rate of 4.7 percent, compared with 9.1 percent when he took office.

While a stronger candidate than he was eight years ago, Beauprez, like Hickenlooper, also stumbled.

During a debate, Beauprez said intrauterine devices, or IUDs, cause abortions. The devices are a common form of birth control used to prevent pregnancy. Then a television ad Beauprez released criticizing Hickenlooper on public safety referred to the death of Colorado Corrections Director Tom Clements, who was killed by a former inmate. The ad prompted Clements' widow to ask Beauprez to stop politicizing the tragedy.

Find Ivan Moreno on Twitter: http://twitter.com/IvanJourno