WASHINGTON — President Donald Trump has signed into law legislation funding the government through the end of September, ending the threat of a partial government shutdown and capping off a struggle in Congress that deeply divided Democrats.

Harrison Fields, the White House principal deputy press secretary, said in a post on X that Trump signed the continuing resolution Saturday.

The bill largely keeps government funding at levels set during Joe Biden’s presidency, though with changes.

It trims nondefense spending by about $13 billion from the previous year and increases defense spending by about $6 billion, which are marginal changes when talking about a top-line spending level of nearly $1.7 trillion.

The Senate cleared the legislation on Friday in a 54-46 party line vote, with 10 members of the Senate Democratic caucus helping the bill advance to passage despite opposition from within their party — most vocally from colleagues in the House.

Senate Democrats argued for days over whether to force a shutdown, livid that Republicans in the House had drafted and passed the spending measure without their input. Democrats said the legislation shortchanges health care, housing and other priorities and gives Trump wide leeway to redirect federal spending even as his administration and the Department of Government Efficiency rapidly dismantle congressionally approved agencies and programs.

— The Associated Press