The legislative session started with Gov. Nathan Deal helping lawmakers avoid dicey votes on hospital bed fees and the new Falcons stadium. It ended with legislators approving the bulk of his agenda — and failing to pass a gun measure that would have given him fits.

Over a 40-day period, Deal and his aides will evaluate dozens of pieces of legislation often hashed out behind closed doors in the frenzied final hours of the session that ended Thursday, measures that could raise legal concerns and test his political savvy as he fights for re-election next year. Anything he doesn’t sign or veto in that window automatically becomes law.

He must debate controversial measures that expand the crackdown on illegal immigrants and fundamentally change the state’s approach to video gambling. He must scrutinize final changes to the $19.9 billion budget that didn’t land on lawmakers’ desks until late Thursday. And he must come to terms with an ethics overhaul that clearly doesn’t thrill him.

Still, the vetting process could have been more harrowing for Deal had lawmakers adopted an effort to expand access to guns across Georgia. That got tripped up in a fight over whether to allow firearms on colleges and universities after Deal pushed for more safety training for people seeking those permits.

It also would have put him in an uncomfortable bind between gun rights groups seeking looser restrictions and university administrators who fought back against so-called “campus carry” rules.

It’s a fight that will carry over the summer.

If that gun legislation had passed, Georgia would have attracted national scrutiny at a time when many states are wrestling with whether to tighten firearms restrictions in the wake of mass shootings such as the Newtown, Conn., school massacre in December. State Rep. Alan Powell, R-Hartwell, has already begun pushing the bill for next year.

“We were fighting an uphill battle,” Powell said of this attempt.

The governor has plenty more on his plate, including many of his top legislative priorities. Lawmakers unanimously adopted a sweeping rewrite of the state’s juvenile justice rules as part of a cost-cutting measure aimed at reserving expensive prison bed space for the most violent offenders.

And Deal plans to sign legislation that would reinstate the 2.0 grade-point average for technical college students to be eligible for the HOPE Grant, allowing thousands more students to qualify for the program after it was overhauled two years ago.

He’s also virtually assured to approve new ethics rules that cap gifts from registered lobbyists at $75, the first time Georgia has placed any limits on the practice. But he’s struggled to hide his displeasure with the final result, which contains numerous exceptions that critics say do little to prevent any abuse.

In an interview, Deal called it an important “first step” but didn’t mask his concern over the final result.

“I’m sure in the future someone would like to tighten it,” he said.

Separate bills tweaking Georgia’s immigration rules also will get a close look from state attorneys. One is aimed at making it harder for illegal immigrants to get state driver’s licenses and other benefits, while the other gives foreign executives quicker access to driving permits.

One of the biggest changes on tap involves new rules governing video gambling. The machines were outlawed in 2001, but they have proliferated in the back rooms of gas stations and convenience stores over the past 12 years. Under new guidelines, the machines would still be banned from dispensing cash but could reward players with store merchandise and, for the first time, lottery tickets. The state lottery would eventually take a 10 percent cut of the revenue.

It’s not yet known how much money that would involve, but critics say it’s not worth risking more competition to the lottery’s games. Social conservatives and religious activists, meanwhile, fear it opens the door to a broader gambling expansion down the line.

“As long as they can tie a dollar in the minds of the beholder to schools and education, they can support it,” said Jerry Luquire, president of the Georgia Christian Coalition. “It’s just a matter of time until we have casino gambling.”

Deal, for his part, has signaled he would sign the video gambling legislation.

“I was pleased with the final result,” Deal said. “There was a lot of misinformation that was put out on that legislation.”

Perhaps looming largest is the minefield of lower-profile legislation approved in the session’s final minutes with little legislative oversight. The rapid-fire process was so pronounced in the Senate that some lawmakers complained they didn’t know what they were voting on. Often, a bill’s sponsor would simply announce that the proposal had been amended without discussing the changes.

“We were ignored. I’ve never in 20 years seen anything like it,” said Senate Minority Leader Steve Henson. “People don’t know what they’re voting on. It’s abusive.”

And Deal must navigate all these pitfalls while keeping one eye on his re-election campaign. He’s planning to visit lawmakers around the state in the coming months as he builds his case for another term, and is eager to avoid any pitfalls during the vetting process.

“I think we have had a very good session, one that you can be proud of when you go back home,” Deal told lawmakers Thursday night.