WASHINGTON — Congressional leaders reached a bipartisan agreement on Sunday to fund the government through September, effectively ending any suspense about the possibility of a government shutdown next weekend.

The agreement, which still must be voted on by lawmakers, includes increased funding for the military and for border security. But it does not include funding for the wall that President Trump wants to build along the border with Mexico, one of his major campaign promises.

The deal increases funding for the National Institutes of Health, despite the Trump administration’s request that its budget be reduced for the rest of the fiscal year. And it provides millions of dollars to reimburse costs incurred by local law enforcement agencies to protect Mr. Trump and his family — a boon to New York City, which has had the costly task of helping to protect Trump Tower.

The Run-Up

The podcast that makes sense of the most delirious stretch of the 2016 campaign.

The spending package would be the first significant bipartisan measure approved by Congress during the Trump presidency. Republicans, despite having control of both houses of Congress and the White House, were unable to pass any marquee legislation in the president’s first 100 days.

The deal should spare Republicans the embarrassment of seeing the government shut down on their watch. But it also gave a glimpse of the reluctance of lawmakers to bend to Mr. Trump’s spending priorities, like his desire for sharp cuts to domestic programs, with the increase in funding for medical research a prime example. And it leaves the border wall looming as a fight in future spending negotiations, especially if Mr. Trump presses the issue, as he vowed to do during a rally Saturday night to mark his 100th day in office.

Details of the agreement were not yet public on Sunday night, but several congressional aides described key parts of it. The measure will cover the rest of the fiscal year, which ends Sept. 30.

Lawmakers had already taken action to keep the government open while they finalized the spending agreement. On Friday, Congress approved a one-week spending measure that averted a shutdown on Saturday.

In recent days, the spending talks on Capitol Hill had seemed unlikely to result in the kind of impasse that could lead to a shutdown, the last of which occurred in 2013. Some key obstacles, including the border wall and a standoff over subsidy payments to insurers under the Affordable Care Act, seemed to fall away as congressional negotiators worked on a deal. The White House said last week that it would continue to make the payments, and that message reassured Democrats who wanted to ensure that the payments, which go to insurers to lower deductibles and other out-of-pocket costs for low-income consumers, would not be cut off.

Lawmakers were able to reach a resolution in the spending package on another potential sticking point, the fate of retired coal miners who faced losing their health coverage, an issue that brought lawmakers close to a government shutdown in December. The deal provides a permanent extension of health coverage for the retired miners.

Though the spending agreement saves the president and congressional Republicans from the specter of a shutdown during a period of one-party rule, it does deprive Mr. Trump of a major victory on the border wall, and Democrats seemed pleased with how they fared.

“This agreement is a good agreement for the American people and takes the threat of a government shutdown off the table,” Senator Chuck Schumer of New York, the minority leader, said in a statement. “The bill ensures taxpayer dollars aren’t used to fund an ineffective border wall, excludes poison-pill riders, and increases investments in programs that the middle-class relies on, like medical research, education and infrastructure.”

He added that Democrats had “clearly laid out our principles” early in the debate, and argued that the final measure “reflects those principles.”

Representative Nancy Pelosi of California, the Democratic leader, cheered the deal as a “sharp contrast to President Trump’s dangerous plans to steal billions from lifesaving medical research” and expressed relief that the bill would not pay for an “immoral and unwise border wall or create a cruel new deportation force.”

As of late Sunday, neither Senator Mitch McConnell of Kentucky, the majority leader, nor the House speaker, Paul D. Ryan of Wisconsin, had issued statements appraising the agreement. A spokeswoman for the House Appropriations Committee, Jennifer Hing, said, “The agreement will move the needle forward on conservative priorities and will ensure that the essential functions of the federal government are maintained.”

The negotiations took place in recent days amid a furious scramble inside the White House to demonstrate progress before Mr. Trump’s 100th day in office. Republicans in the House still hope to advance a revised version of their bill to repeal and replace the Affordable Care Act.

Last week, the revised bill earned the backing of the hard-line House Freedom Caucus, though the changes gave pause to numerous moderate Republicans, including some who had backed the initial proposal.

It was unclear when a vote on the revised measure might occur, despite pressure from the White House. Republican leaders in the House have said repeatedly that a vote will come when they have enough support to pass the bill.