President Trump on Tuesday threatened to veto an annual defense bill authorizing nearly $1 trillion in military spending unless Congress opens the door for Facebook, Twitter and other social media sites to be held legally liable for the way they police their platforms.

Trump delivered his ultimatum — calling for the repeal of a federal law known as Section 230 — in a pair of late-night tweets that transformed a critical national security debate into a political war over his unproved allegations that Silicon Valley’s technology giants exhibit systemic bias against conservatives.

“Section 230, which is a liability shielding gift from the U.S. to ‘Big Tech’ (the only companies in America that have it — corporate welfare!), is a serious threat to our National Security & Election Integrity,” Trump tweeted.

Unless the “very dangerous & unfair Section 230 is not completely terminated as part of the National Defense Authorization Act (NDAA),” Trump continued, “I will be forced to unequivocally VETO the Bill when sent to the very beautiful Resolute desk.”

President Trump on May 28 signed an executive order seeking to change Section 230, a federal law that protects tech companies. (The Washington Post)

Section 230 is a broad, decades-old federal law that spares a wide array of sites and services from being held liable for the content posted by their users — and, in the process, the decisions about the posts, photos and videos that tech companies take down or leave online. It is considered one of the Web’s foundational laws, crafted in large part to facilitate free expression digitally.

Many lawmakers — Democrats and Republicans — increasingly have come to question whether the protections are outdated, conferring legal immunity on tech giants at a time when they have failed to crack down on hate speech, election disinformation and other harmful content online. But Trump and his Republican allies have seized on the debate to advance their arguments that Facebook, Google, Twitter and others should be penalized for exhibiting systemic political bias against conservatives — a charge for which they have provided scant evidence, and one that tech giants long have denied.

Trump has stepped up his attacks in recent months, particularly as social media companies have taken more aggressive action against his most controversial online posts — including his tweets falsely claiming he won the 2020 presidential election. Earlier this year, the president also signed a sweeping executive order that sought to give the government vast new power to police political speech on the Web, a directive later challenged in court over its constitutionality. And Trump has repeatedly urged state and federal investigators to use their broad investigatory powers to probe, and potentially punish, Silicon Valley over allegations of bias.

Section 230 otherwise has no nexus with national security. A White House spokesman did not respond to a request for comment late Tuesday about the president’s contention that the law puts the country at risk.

Trump’s ultimatum arrives after he previously threatened to veto the roughly $740 billion defense bill, known as the NDAA, over a provision that would require the Pentagon to change the names of 10 military installations that recognize Confederate military officers who fought to preserve slavery. Trump has said he will not allow that to happen, and he grew angry when defense officials said that Defense Secretary Mark T. Esper, whom Trump has since fired, and Army Secretary Ryan McCarthy had signaled openness to the bases being renamed.

Sen. James M. Inhofe (R-Okla.), the chairman of the Senate Armed Services Committee, told The Washington Post in an interview last month that Senate Majority Leader Mitch McConnell (R-Ky.) has a policy against putting bills on the floor for a vote when they have a veto threat.

But some Republicans in recent days have suggested a trade: Reforming Section 230 in exchange for the base-name changes that Democrats seek, according to a person familiar with the matter, who requested anonymity to describe the private conversations. Democrats largely have balked at the idea, the source said.

Dan Lamothe contributed to this report.