The bill also limits Trump's ability to immediately withdraw all remaining US troops from Afghanistan
President Donald Trump suffered a stinging rebuke in the US Senate on Friday when fellow Republicans joined Democrats to override a presidential veto for the first time in his tenure, pushing through a defense policy bill he opposed just weeks before he leaves office.
Meeting in a rare New Year's Day session, senators voted 81-13 to secure the two-thirds majority needed to override the veto.
Eight previous Trump vetoes had been upheld and until Friday's vote, he had been on track to be the first president since Lyndon Johnson with none overridden.
The Senate also ended for now a push by Democrats to increase Covid-19 financial relief checks from $600 to $2,000, a change sought by Trump. The effort was blocked by Republicans.
Republican lawmakers have largely stood by the president during his turbulent White House term.
Since losing his re-election bid in November, however, Trump has lashed out at them for not fully backing his unsupported claims of voter fraud, for rejecting his demand for bigger Covid-19 relief checks, and for moving to override his veto.
In another setback for Trump, a judge rejected a lawsuit filed by a Texas lawmaker and other Republicans against Vice President Mike Pence seeking to overturn Democratic President-elect Joe Biden's win. Pence is set to preside on Wednesday over a joint session of Congress to formalize the results of the election.
The Democratic-controlled House of Representatives on Monday voted to override Trump's defense bill veto. A president has the power to veto a bill passed by Congress, but lawmakers can uphold the bill if two-thirds of both houses vote to override the veto.
The $740 billion National Defense Authorization Act (NDAA) determines everything from how many ships are bought to soldiers' pay and how to address geopolitical threats.
Trump refused to sign it into law because it did not repeal certain legal protections for social media platforms and included a provision stripping the names of Confederate generals from military bases.
"We've passed this legislation 59 years in a row. And one way or another, we're going to complete the 60th annual NDAA and pass it into law before this Congress concludes on Sunday," Senate Republican Leader Mitch McConnell had said ahead of the vote.
Democratic House Speaker Nancy Pelosi accused the president of using his final weeks in office "to sow chaos," saying in a statement that Congress urged him to "end his desperate and dangerous sabotage."
The bill also overhauls anti-money laundering rules and banning anonymous shell companies, making it easier to police illicit money flows.
US weak rules on disclosing corporate owners have allowed criminals to use legal entities to shuffle their cash around the world, according to the authorities.
The vote could have implications for two US Senate runoff elections in Georgia on Tuesday that will decide control of the chamber under Biden, who takes office on January 20. The senators facing a runoff, Republicans David Perdue and Kelly Loeffler, strongly back both Trump and the military.
Neither Perdue nor Loeffler voted on Friday. Neither did another staunch Trump ally, Senator Lindsey Graham. Perdue entered quarantine this week after contact with someone who tested positive for Covid-19. Spokesmen for Loeffler and Graham did not respond to requests seeking comment.
The push to have Confederate names stripped from US bases gained momentum after George Floyd, an unarmed black man, was killed by a Minneapolis police officer last May, triggering protests over racial injustice.
The legislation requires the defense secretary to establish a commission with 45 days to develop a plan to remove the names of Confederate soldiers and leaders from Defense Department property and to implement that plan within three years.
Among the bases that would require a name change is the largest US Army base, Fort Bragg in North Carolina, named for Confederate General Braxton Bragg.
The bill also limits Trump's ability to immediately withdraw all remaining US troops from Afghanistan.
It requires him to submit a "comprehensive, interagency assessment of the risks and impacts before using funds to draw down US military personnel in Afghanistan below 4,000 or current levels and again before drawing down below 2,000," a summary says.
As votes were being counted indicating Trump had lost, the president took to Twitter to tout a protest rally being planned in Washington on Wednesday, when the new Congress meets to officially tally the Electoral College votes certifying Biden's victory.
Some Trump allies have said they plan to object on Trump's behalf, including Senator Josh Hawley who expects to be joined by as many as 140 other House Republicans, but the objections are expected to be dismissed by the majority of lawmakers.
Hawley acknowledged he is still undecided about how many state election results will be the targets of his objections.
Republican Senator Ben Sasse blasted the move in a Facebook post on Wednesday, saying: "Adults don't point a loaded gun at the heart of legitimate self-government."
In a tweet, Trump denounced the Senate's refusals to lift legal protections for social media platforms or to take up his call for more Covid-19 relief as "Pathetic!!!" and "not fair, or smart!"