BRANCHBURG, N.J. — President Trump signed his first piece of major legislation on Friday, a $1 trillion spending bill to keep the government operating through September.
The bill cleared both houses of Congress this week and Trump signed it into law behind closed doors at his home in central New Jersey, well ahead of a midnight Friday deadline for some government operations to begin shutting down.
But other budget battles lie ahead as the White House and Congress hammer out a spending plan for the fiscal year that starts Oct. 1.
Republicans praised $15 billion in additional Pentagon spending obtained by Trump, as well as $1.5 billion in emergency spending for border security, though not for the wall he has vowed to build along the US-Mexico border to deter illegal immigration.
Trump also wants a huge military buildup matched by cuts to popular domestic programs and foreign aid accounts.
Republicans and Democrats who negotiated the measure Trump signed Friday had successfully defended other accounts Trump had targeted for spending cuts, such as foreign aid, the Environmental Protection Agency, support for the arts, and economic development grants, among others.
The sweeping, 1,665-page bill also increases spending for NASA, medical research, the FBI, and other federal law enforcement agencies.
Trump took to Twitter this week to complain about the bipartisan process that produced the measure but later changed his tone and began highlighting the spending that was added for the military and for border security.
He advocated in one tweet for a ‘‘good shutdown’’ in September to fix the ‘‘mess’’ that produced the bill, but then appeared in the White House Rose Garden hours later to boast that the measure amounted to a big win for him.
In other areas, retired union coal miners won a $1.3 billion provision to preserve health benefits for more than 22,000 retirees. House Democrats won funding to give Puerto Rico’s cash-strapped government $295 million to help ease its Medicaid burden.
Trump is working a long weekend from his residence at a golf club in Bedminster. The White House claims staying in New Jersey saves taxpayers money, compared with the cost of staying at Trump Tower in New York, although it is estimated to cost the government and local authorities hundreds of thousands of dollars.
In other matters Friday:
■ Army secretary: Mark Green, the Republican state senator from Tennessee who was picked by Trump to be Army secretary, has withdrawn from consideration. He stepped aside amid intensifying criticism over his remarks about LGBT Americans and Muslims.
Green is the second Trump nominee for Army secretary to withdraw. Several Democrats have denounced Green for declaring that being transgender is a disease. He is opposed to gay marriage.
Green said ‘‘false and misleading attacks’’ against him have made his nomination a distraction. He said his life of public service and Christian beliefs have been mischaracterized for political gain.
During a speech last September, Green urged that a stand be taken against ‘‘the indoctrination of Islam’’ in public schools. He also referred to the ‘‘Muslim horde’’ that invaded Constantinople centuries ago.
■ White House drug czar: The Trump administration is moving to gut the office of the White House ‘‘drug czar,’’ according to a preliminary budget document and an e-mail that its acting director has circulated to agency staff.
The Office of National Drug Control Policy is the lead White House office shaping policy on the nation’s opioid crisis, among other responsibilities.
The proposed $364 million cut would leave a budget of just $24 million for the office and would eliminate its two major grant programs.
■ Religion and politics: A Wisconsin-based atheist group has filed a lawsuit asking a federal judge to strike down Trump’s order easing enforcement of an IRS rule limiting religious organizations’ political activity.
A 1954 federal law prohibits tax-exempt charitable organizations such as churches from participating in political campaigns. Violators could lose their tax-exempt status, but the law has rarely been enforced.
The IRS doesn’t make its investigations of such cases public, but only one church is known to have lost its tax-exempt status as a result of the law. Still, Trump has long promised conservative Christians who supported his White House bid that he would block the regulation.
On Thursday the president issued an executive order directing the Treasury Department not to take ‘‘adverse action’’ against churches or religious organizations for political speech.
The Freedom from Religion Foundation filed a lawsuit hours later. It argues in the filing that the order is unconstitutional because it grants preferential treatment to religious organizations while secular groups must still abide by the law.