Maryland Gov. Larry Hogan, second from right, walks down a staircase in the Maryland State House to speak at a news conference following the Maryland legislative session in Annapolis, Md., early Tuesday, April 11, 2017. (Patrick Semansky/AP)

Maryland Gov. Larry Hogan, who has clashed with Democratic legislative leaders and struggled to get bills passed over the past two years, just finished his most successful legislative session since taking office in 2015.

Hogan, a Republican who enjoys wide popularity in the deep-blue state, got his major win in his final legislative session before he gears up for reelection next year.

In the final hours of the 2017 legislative session, which ended Monday night, the General Assembly passed a jobs bill, offered by the governor, that provides tax breaks to manufacturing companies that locate in Baltimore and other economically depressed areas.

“The passage of that manufacturing bill allows him to really continue on the economic- and job growth-centered message that put him in office,” Mileah Kromer, a political scientist at Goucher College, said of the governor.

The General Assembly also passed an ethics bill, proposed by Hogan, that strengthens the state’s laws, and it rolled back new transportation-funding rules that Hogan said would force his administration to cancel plans for much-needed road and bridge projects.

Maryland Gov. Larry Hogan, center, sits between Senate President Thomas V. Mike Miller, left, and House Speaker Michael Busch while signing a series of bills during a ceremony following the state’s legislative session in Annapolis, Md., Tuesday, April 11, 2017. (Patrick Semansky/AP)

House Speaker Michael E. Busch (D-Anne Arundel) said the passage of the ethics bill and other bipartisan legislation were symbolic of “the working relationship” between Democratic and Republican leaders this year.

“I think it was a session we can all be proud of,” he said.

But Sen. Richard S. Madaleno Jr. (D-Montgomery), who is considering a run for governor in 2018, offered a less-sanguine take on Democratic relations with the governor, saying the Hogan administration engaged with the legislature this year only “on a handful of issues that are important” to Hogan.

“They were very engaged on the manufacturing bill,” he said. “They’re very engaged on the issues that he cares about. But he avoids getting his hands dirty on any issue that isn’t adequately poll-tested in advance.”

Along with several Democratic proposals, the legislature approved Hogan’s plan to stem the rising number of heroin overdoses. It also changed the definition of sex abuse in state law to include sexual trafficking of a child, part of an effort by the governor to address an increase in human trafficking.

“It is, by far, the best session we’ve ever had,” Hogan said Monday night, hours before the legislature adjourned. “We got more accomplished in the last 90 days than we did in the last two [sessions] added together. I’m not sure it could have been more successful.”

Hogan also failed on a number of bills he had prioritized. All these measures died in this session: an effort to establish a nonpartisan commission to draw the state’s voting boundaries, a measure to increase penalties for repeat drunk drivers and a bill that would have required employers with 50 or more workers to provide paid sick leave. Instead, the Democrats approved their own paid sick-leave bill, which calls for companies with 15 or more workers to provide the benefit.

During a bill signing Tuesday, Hogan repeatedly praised the “hard work of these two gentlemen,” referring to Busch and Senate President Thomas V. Mike Miller Jr. (D-Calvert).

For their part, Maryland Democrats focused much of their attention this session on another Republican: President Trump.

Several bills were aimed at defending Maryland against Trump policies on health care, immigration, consumer protections, education and the environment.

Democrats have repeatedly tried to tie Hogan to the less-popular Trump, often calling on him to publicly address Trump’s push to repeal the Affordable Care Act, cut funding for the Chesapeake Bay and ban Muslims from eight countries from entering the United States.

Hogan has largely remained silent, trying to distance himself from Trump and saying he is focused on state affairs.

Hogan refused to sign several anti-Trump bills the General Assembly sent to his desk two weeks ago, instead allowing the measures to become law without his signature. Those measures include a bill that provides funds for the state attorney general to sue the Trump administration; a measure that requires the state to reimburse Planned Parenthood clinics if Congress cuts their funding, and bills to create commissions to study the impact of federal policies on health care and consumer protections.

Hogan took one of his most vocal positions on the Trust Act, a bill that would have prohibited state and local police from helping enforce federal immigration efforts by asking people about their immigration status.

It would have banned most Maryland jurisdictions from detaining undocumented people past their release date unless federal agents who want to deport them have a warrant or court order describing probable cause.

The measure passed the House but died in the Senate after Miller warned that “Maryland is not going to become a sanctuary state.”

Observers said Hogan can claim the death of the bill a victory.

“He’s managed to go through this entire session and still not be painted by the Trump brush,” said Todd Eberly, a political science professor at St. Mary’s College.

Still, Eberly said he thinks most Democrats were resigned during last session to think that Hogan would be reelected. After Trump’s election, he said, “I’m not so sure they think that now.”

A recent poll by The Washington Post and the University of Maryland found that Hogan’s support for reelection lags far behind his 65 percent approval rating. About 41 percent of registered voters said they would support the governor for a second term; 37 percent said they’d prefer a Democrat.

The poll also found that Hogan could be vulnerable to an anti-Republican backlash. Former governor Robert L. Ehrlich Jr., the state’s last Republican governor, lost to former governor Martin O’Malley (D) in 2006 despite his high poll ratings, in part because of an anti-Republican backlash.

Eberly said Democrats accomplished the goal to “take on Trump” but appeared to fall short linking Hogan to Trump.

“It’s [Hogan’s] third session, and they are still trying to figure out how to take him on politically,” Eberly said.

Josh Hicks contributed to this report.