FILE PHOTO: A view from the U.S. Senate side shows the U.S. Capitol Dome (L) in Washington, U.S., October 4, 2013. REUTERS/Jonathan Ernst/File Photo

WASHINGTON (Reuters) - The U.S. Senate voted overwhelmingly on Thursday for legislation to fund much of the government, including $675 billion for the Department of Defense, as lawmakers worked to minimize the risk of a government shutdown before the fiscal year ends Sept. 30.

The Senate voted 85-7 to pass the $854 billion measure, which combines funding for the Pentagon with money for domestic programs including the Health and Human Services, Education and Labor Departments.

Leaders of the Senate and the House have been trying to pass appropriations bills before Sept. 30 and avoid the threat of government shutdowns and the need for stopgap spending measures that have been common for several years.

The Senate’s Republican and Democratic leaders agreed to combine the bills to increase their chances of passage in the chamber, where Republicans have just a 51-49 majority.

Republicans generally favor increased military spending, and Democrats have been pushing to fund domestic programs. The two parties also agreed not to allow controversial amendments, also in the hope of boosting chances of passage.

However, to become law, the spending plans must be approved by the House of Representatives, which is out of Washington until September and where President Donald Trump’s fellow Republicans have a much larger majority.

They must also be signed by Trump, who has expressed strong reservations about some aspects of the package and said he would welcome a government shutdown if necessary to win funding for his proposed wall on the border with Mexico.