Maryland House Speaker Michael E. Busch (D) at a news conference in Annapolis on March 8 in support of legislation to continue funding for services provided by Planned Parenthood. (Brian Witte/AP)

Democrats in the Maryland General Assembly spent much of the 2017 legislative session opposing President Trump’s agenda; taking progressive stances on education, health care and the environment; and trying to dent Republican Gov. Larry Hogan’s popularity ahead of the 2018 gubernatorial election.

On Monday, the House and Senate spent the last day of the session squeezing in final votes and trying to negotiate agreements on controversial bills dealing with police treatment of undocumented immigrants and banning guns on college campuses.

By evening, talks on the latter two proposals appeared to have fallen apart, and a bill on Internet privacy died in committee. But lawmakers passed bills to prevent price gouging by drugmakers, limit hours of standardized testing in schools, address a growing opioid epidemic, provide a tax break for new and expanding manufacturers, and roll back new transportation-funding rules that Hogan said would force his administration to cancel plans for much-needed road and bridge projects.

Legislators continued working late into the evening to resolve a dispute over the state’s medical-marijuana industry.

Hogan, who proposed his most robust agenda since taking office in 2015, described this year’s session as “incredibly bipartisan” but acknowledged that he and Democrats “had a few heated moments here and there on different topics.”

Maryland Senate President Thomas V. Mike Miller (D) speaks with reporters in the Senate chamber on Jan. 11, the first day of the 2017 legislative session. (Patrick Semansky/AP)

Much of the heavy lifting for the Democratic agenda wrapped up before Monday, including the passage of a bill requiring employers to provide paid sick leave.

“The session has been all about the Democrats playing defense, fighting against Trump and defending the Maryland worker and the Maryland environment,” said Mileah Kromer, a political scientist at Goucher College. “That plays well to a progressive base that is still reeling from the Trump presidency . . . but they did not hit Larry Hogan where he is the strongest — on jobs and the economy.”

The General Assembly sent to the governor’s desk measures that would prohibit public and private colleges from including questions about criminal history on their applications, ban suspensions of prekindergarten students and require the state to begin work on a nonpartisan redistricting compact with New York, New Jersey, Pennsylvania, Virginia and North Carolina.

Immigration advocates pressed lawmakers this year to enact a bill that would limit police cooperation with federal deportation agents, one of several ways progressives want to fight Trump’s agenda. The measure, known as the Trust Act, passed the House in March, but a Senate committee advanced only portions of the measure last week, after Senate President Thomas V. Mike Miller Jr. (D-Calvert) warned that “Maryland is not going to become a sanctuary state.”

Negotiations over the measure stalled Monday, exposing divisions among Democrats, as progressive House members lashed out at Miller and Sen. Bobby A. Zirkin (D-Baltimore County), the chairman of a committee that removed language barring police and corrections officers from detaining undocumented immigrants on behalf of immigration authorities unless they have a judicial warrant.

“We’ll continue to fight for those communities, even if the Senate and the leadership won’t,” said Del. Carlo Sanchez (D-Prince George’s), who chairs the Legislative Latino Caucus. “It doesn’t look good. We’re not getting the language we want.”

Hogan vowed to veto the original version of the Trust Act but has not taken a stance on the Senate committee’s modified plan, which would prohibit local police from stopping and questioning individuals solely to determine their immigration status, and from creating registries based on discriminatory factors such as race and religion.

Meanwhile, bail-reform advocates and the Legislative Black Caucus scored a victory last week when House Speaker Michael E. Busch (D-Anne Arundel) said a pro-bail bill would not receive a vote in the House this year.

The legislation, strongly backed by the bail-bond industry, would have reversed a recent Court of Appeals rule change that limits the use of bail and instructs judges to impose the “least onerous” conditions when setting the terms of a defendant’s pretrial release.

Lawmakers also passed three bills to combat the opioid crisis, including measures that would require doctors to follow best practices for prescribing pain pills; ramp up public-awareness efforts at schools; increase reimbursement rates for care providers who work with addicts; and create a new felony category for distribution of fentanyl, a highly potent synthetic opioid that is often mixed with heroin.

But a Senate bill that would have enshrined in state law the federal Internet-privacy regulation created by the Obama administration failed to move out of the House Economics Matters Committee late Monday. Del. Dereck E. Davis (D-Prince George’s), chairman of the committee, said there was not enough time for his committee to thoroughly consider the late-filed bill, which was introduced in the Senate last week and forwarded to the House on Monday evening.

In the past several days, the legislature has forwarded dozens of bills to the governor’s desk, including several progressive measures that change the way schools are rated for success and prohibit private companies from taking over failing public schools, ban hydraulic fracturing in Western Maryland and require the state to reimburse Planned Parenthood clinics for their services if Congress cuts funding.

The General Assembly also authorized the attorney general to sue the Trump administration over policies dealing with health care, immigration and the environment, and it formed commissions to study the impact of federal policies affecting health care and consumer protections.

Last week, Hogan, opting against a veto override showdown with the legislature, allowed almost all of the bills that were sent to his desk early to become law. He vetoed just one bill, the education accountability bill, which largely pitted the teachers union and Democrats against the State Board of Education and Hogan.

The majority of the bills, including the one that provides funding for Planned Parenthood and all of the measures aimed at the White House and Capitol Hill, became law without Hogan’s signature.

“We’ve had a great session,” Miller said. “We worked with the governor, sent him 27 bills; he vetoed one.”

House Majority Leader C. William Frick (D-Montgomery) said the Democrats have largely had to focus on “legislating Maryland values, because Maryland values are not coming out of Washington right now.”

But Republicans said the attention on Washington was unnecessary, accusing Democrats of trying to tie Hogan, a popular Republican, to Trump, who is widely unpopular in Maryland.

“They tried their best to bring D.C. politics into Annapolis,” House Minority Whip Kathy Szeliga (R-Baltimore County) said. What the Democrats “did was a partisan reaction to anything coming out of Washington.”

The session opened with a stain of scandal, and it ended in similar fashion. On Jan. 11, the day the legislature convened, Del. Michael Vaughn (D-Prince George’s) abruptly resigned; he was later implicated in a wide-ranging federal bribery investigation. On Friday, Sen. Nathaniel T. Oaks (D-Baltimore) turned himself in to federal authorities on separate bribery charges.

The legislature last week passed a bill designed to strengthen the state’s ethics laws, a step Hogan proposed after earlier scandals. On Friday, Miller added an amendment to increase the penalty for bribery to 12 years in prison and a $10,000 fine.

“We are reaffirming our promise and commitment to the accountability, transparency and fairness that the people of Maryland deserve,” Hogan said.

Fenit Nirappil contributed to this report.