The idea that the United States could withdraw from NATO is surreal.

The alliance, now numbering 29 countries, has been the foundation of trans-Atlantic stability and prosperity for seven decades. It continues to keep a predatory Russia at bay and diminish the danger that American soldiers might once again have to fight on European soil.

Yet in Donald Trump’s go-it-alone presidency, the possibility of America’s withdrawal has become such a concern that Congress is taking steps to prevent it.

The Democratic-led House on Jan. 22 voted 357-22 for a bipartisan bill that would tie Mr. Trump’s hands by refusing him any federal money to pay the costs of leaving the alliance.

The Republican-led Senate should quickly follow, either approving the House measure or a separate bill proposed by a bipartisan group of senators that requires Mr. Trump to obtain approval from two-thirds of the Senate to “suspend, terminate or withdraw U.S. membership in NATO.” If the president refused to abide by a Senate vote preserving NATO membership, the bill would then prohibit the use of federal funds for withdrawal.