Secretary of State Rex Tillerson testifies before the Senate Foreign Relations Committee last week. (Aaron P. Bernstein/Reuters)

CONGRESS RARELY takes the lead in foreign affairs, but senators in both parties have risen to the occasion in recent weeks, exhibiting an uncommonly independent and disciplined response to the tumult of President Trump’s administration. The latest votes and hearings are a welcome sign that Congress can act as a responsible counterweight to Mr. Trump’s more erratic impulses.

Last week the Senate voted 98 to 2 — how often does that happen? — for the first major piece of foreign policy legislation the chamber has considered this year, a bill stepping up sanctions against Iran and Russia. While Mr. Trump has broadly declared a desire to improve ties with the Kremlin and was seen recently joshing in the Oval Office with the Russian foreign minister and ambassador, the Senate vote reflects a far more sober assessment of President Vladimir Putin’s meddling in the U.S. election, subversion in Ukraine and intervention to save the brutal leader of Syria. The legislation, with bipartisan backing, will make it impossible for Mr. Trump to lift sanctions against Russia without congressional approval, and places new penalties on Russian energy exports. There’s been much debate lately about whether Mr. Putin’s hacking against the United States last year was a shrewd move for him and for Russia; the Senate vote suggests it has badly backfired.

Another example was a Senate vote that can be seen only as a rebuke to Mr. Trump’s handling of a bedrock issue, the Atlantic alliance. Mr. Trump delivered a speech May 25 at NATO’s new headquarters in which he omitted a sentence affirming the long-standing U.S. commitment to Article 5 of the North Atlantic Treaty, the pledge that an armed attack against one will be considered an attack against all. Mr. Trump made a lame attempt to recover June 9, once back at the White House, but the damage had been done. His omission was dangerous and could lead allies to doubt American resolve at a time of growing tension with Russia. The Senate, wanting to make sure there is no ambiguity, voted 100 to 0 for an amendment reaffirming U.S. support for the alliance.

Meanwhile, Mr. Trump has proposed a debilitating 30 percent cut in the fiscal 2018 budget of the State Department, one of the deepest cuts in any federal agency. When Secretary of State Rex Tillerson went before the Senate Foreign Relations Committee last week, he got a truckload of bipartisan criticism about the risk of such cuts in a department dedicated to defending American interests abroad. Chairman Bob Corker (R-Tenn.) declared that even looking at the Trump budget was a “total waste of time” because it was dead on arrival. The senators repeatedly and wisely pointed out to Mr. Tillerson that U.S. security is enhanced not only by military might but also programs that promote democracy and prevent nuclear proliferation. They also questioned him about the snail’s pace of filling the department’s top jobs.

Everyone ought to be grateful that Congress, so often fractious and hyper-partisan, has seen fit to grab the foreign policy wheel, and steady it.