WASHINGTON — The House passed a bipartisan bill to fund much of the Department of Homeland Security, ending the longest agency shutdown in history. House Speaker Mike Johnson presided over the vote following overnight sessions and closed-door negotiations on Capitol Hill.

Before the vote, which took place near 11 p.m., Johnson huddled behind closed doors for five hours to salvage his agenda. Legislation was written behind closed doors, votes were scheduled on short notice, and the chamber alternated between sessions that lasted through the night and periods with no activity on the floor.

"Sometimes it's an ugly process, sometimes it's a long process," Johnson said after House passage of the bill. "But we got it done."

Johnson took over as Speaker more than two years ago after Kevin McCarthy was ousted, and he is presiding over one of the slimmest House majorities in modern times. He is managing competing priorities from President Donald Trump, the House Freedom Caucus, and more pragmatic House Republicans.

Rep. Richard Hudson described the difficulty of moving legislation with a tight majority. "It can be rough. It's ugly," Hudson said. "I'd be fine with letting us go home and campaign. But we've got a lot of important work still to do."

Democrats offered a different assessment of the proceedings. "House Republicans have shown again that they can't govern," said Rep. Ted Lieu of California. "They routinely pass bills to the Senate that are way too extreme, then it ends up that we have all these floor session days where we're just doing nothing."

Last year, Johnson led passage of a bill of tax breaks and safety net cuts, which Trump signed into law. Johnson and other Republican lawmakers have discussed an agenda to pass a GOP-only budget package without Democratic votes. Republicans previously forced McCarthy, John Boehner and Newt Gingrich from the speaker's office, and they face an uphill climb to keep their slim House majority in the 2026 elections.