WASHINGTON — Congressional leaders have reached an agreement on sweeping sanctions legislation to punish Russia for its election meddling and aggression toward its neighbors, they said Saturday, defying the White House’s argument that President Trump needs flexibility to adjust the sanctions to fit his diplomatic initiatives with Moscow.

The new legislation would sharply limit the president’s ability to suspend or terminate the sanctions — a remarkable handcuffing by a Republican-led Congress six months into Mr. Trump’s tenure. It is also the latest Russia-tinged turn for a presidency consumed by investigations into the Trump campaign’s interactions with Russian officials, including conversations between Trump advisers and Russian officials about prospective sanctions relief.

Now, Mr. Trump could soon face a decision he hoped to avoid: veto the bill — a move that would fuel accusations that he is doing the bidding of President Vladimir V. Putin of Russia — or sign legislation imposing sanctions his administration has opposed.

“A nearly united Congress is poised to send President Putin a clear message on behalf of the American people and our allies,” said Senator Benjamin L. Cardin of Maryland, the top Democrat on the Senate Foreign Relations Committee, “and we need President Trump to help us deliver that message.”

The bill aims to punish Russia not only for interference in the election but also for its annexation of Crimea, continuing military activity in eastern Ukraine and human rights abuses. Proponents of the measure seek to impose sanctions on people involved in human rights abuses, suppliers of weapons to the government of President Bashar al-Assad in Syria and those undermining cybersecurity, among others.

The agreement highlighted the gap between what Mr. Trump sees as the proper approach to a resurgent Russia and how lawmakers — even Republicans who broadly support Mr. Trump — want to proceed. While Mr. Trump has dangled the possibility of negotiating a deal to lift sanctions, Mr. Putin’s top objective, the congressional response is to expand them.

The White House did not respond publicly to the legislation. But two senior administration officials said they could not imagine Mr. Trump vetoing the measure in the current political atmosphere, even if he regards it as interfering with his executive authority to conduct foreign policy. But as ever, Mr. Trump retains the capacity to surprise, and this would be his first decision about whether to veto a significant bill.

Congress has complicated his choice because the legislation also encompasses new sanctions against Iran and North Korea, two countries the administration has been eager to punish for their activities.

There are still hurdles to clear in a Capitol where the Republican majorities have been reticent to confront Mr. Trump. Some party leaders were silent about the agreement on Saturday, including Senator Mitch McConnell of Kentucky, the majority leader, and Senator Bob Corker of Tennessee, the chairman of the Senate Foreign Relations Committee.

Others took care to note the misdeeds of all three countries being targeted for sanctions.

In a statement from two California Republicans — Kevin McCarthy, the House majority leader, and Ed Royce, the chairman of the House Foreign Affairs Committee — the lawmakers said, “North Korea, Iran and Russia have…