Senators have reintroduced a measure meant to keep President Donald Trump from pulling out of NATO.

The measure prohibits funds from being used for a withdrawal and expresses US support for the alliance.

Despite the alliance's popularity, however, the president has broad foreign-policy and military authorities.

Virginia Democratic Sen. Tim Kaine reintroduced a bill on Thursday that would keep President Donald Trump from pulling the US out of NATO — the transatlantic security organization that the US helped form after World War II, toward which Trump has repeatedly expressed disdain.

The bipartisan bill, introduced in 2018 but never voted on, would require "the advice and consent of the Senate or an Act of Congress to suspend, terminate, or withdraw the United States from the North Atlantic Treaty."

"No funds authorized or appropriated by any Act may be used to support, directly or indirectly, any efforts on the part of any United States Government official to take steps to suspend, terminate, or withdraw the United States [from NATO] ... until such a time as the Senate passes, by an affirmative vote of two-thirds of Members, a resolution advising and consenting to the withdrawal of the United States from the treaty or pursuant to an act of Congress," the bill adds.

It also authorizes congressional legal counsel to challenge the Trump administration in court if it tries to pull out of the alliance.

A Polish soldier in a tank in front of a NATO flag. Sean Gallup/Getty Images

The bill also requires the president to notify the committees on foreign affairs in the Senate and House of Representatives in writing of any effort to suspend, terminate, or withdraw from NATO.

"President Trump’s repeated threats to withdraw from NATO are dangerous," Kaine, a member of the Foreign Affairs and Armed Services committees, said in a release.

Read more: Here's how Donald Trump took shots at NATO in 2018 — and it spurred Jim Mattis to quit in protest

Trump's "reckless decision-making — his abrupt withdrawal of US troops from Syria and Afghanistan, his pullout from the Iran nuclear deal and Paris climate agreement, and his deference to Vladimir Putin — is destroying strategic partnerships we have forged with allies across the world," Kaine added.

The bill was also sponsored by Republican Sens. Cory Gardner, Lindsey Graham, Marco Rubio, and Susan Collins, and Democratic Sens. Jack Reed, Chris Coons, and Richard Blumenthal.

Since taking office, Trump has repeatedly inveighed against NATO and its members, criticizing them for what he believes is failure to spend adequately on defense, instead free-riding on the US's contribution to the alliance.

Sean Gallup/Getty Images

NATO members pay to support the alliance's administrative operations, but there is no common pool for defense funds. (The US provides about 22% of the overall budget, but that contribution is scaled to each country's national income.)

Rather, members support the alliance by spending on their own militaries. NATO members agreed in 2014 increase their individual military expenditures to 2% of GDP by 2024. Many members remain short of that goal, as Trump has repeatedly said.

Read more: NATO just held its largest war games since the Cold War — one of more than 100 exercises the alliance carried out in 2018

Trump has made comments supporting NATO in the past, but the reintroduction comes after The New York Times reported that on several occasions during 2018 Trump said in private that he wanted to pull the US out of the alliance.

The Senate measure is not the only one introduced to Congress. The bipartisan "No NATO Withdrawal Act" was introduced in the House in summer 2018. That bill, which did not pass, prohibited funds from being used to withdraw from NATO and said that it was US policy to remain in the alliance.

Trump with other NATO leaders at the opening ceremony at the 2018 NATO summit. Sean Gallup/Getty Images

California Democratic Rep. Jimmy Panetta, a cosponsor of the 2018 bill, reportedly reintroduced it in the House on Thursday.

While lawmakers and the US public largely support the US's membership in NATO, there may be little Congress could do should Trump decide to pull the US out.

Read more: 'We can do better': The Navy's newest fleet commander says US ships and sailors got 'beat up' during NATO's biggest exercise since the Cold War

Congress retains the powers of the purse and the ability to approve treaties, and some legal rulings have checked the president's authority on national-security matters. But the president is responsible for diplomacy and controls the US military.

"The president, in the foreign affairs realm, can exercise a lot of discretion where Congress is silent," Scott Anderson, a Brookings Institution scholar and former State Department lawyer, told Foreign Policy this week.