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 sharply limits the president’s ability to suspend or terminate the sanctions. At a moment when investigations into the Trump campaign’s interactions with Russian officials have cast a shadow over his presidency, Mr. Trump could soon face a bleak decision: veto the bill — and fuel accusations that he is doing the bidding of President Vladimir V. Putin of Russia — or sign legislation imposing sanctions his administration abhors.

The White House has not publicly spoken about the compromise legislation. But two senior administration officials said they could not imagine Mr. Trump vetoing the legislation 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 compromise legislation also encompasses new sanctions against Iran and North Korea, two countries the administration has been eager to punish for its activities.

A sanctions package had stalled in the Republican-led House for weeks after winning near-unanimous support in the Senate last month. Democrats accused Republicans of delaying quick action on the bill at the behest of the Trump administration, which had asked for more flexibility in its relationship with Russia and took up the cause of energy companies, defense contractors and other financial players who suggested that certain provisions could harm American businesses.

The House version of the bill includes a small number of changes, technical and substantive, from the Senate legislation, including some made in response to concerns raised by oil and gas companies.

But for the most part, the Republican leadership appears to have rejected most of the White House’s objections. 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.

Paired with the sanctions against Iran and North Korea, the House version of the bill was set for a vote on Tuesday, according to the office of Representative Kevin McCarthy, Republican of California and the chamber’s majority leader.

On Saturday, the agreement appeared destined for bipartisan, bicameral support.

Senator Ben. Cardin of Maryland, the top Democrat on the Senate Foreign Relations Committee, said that though he would have preferred full adoption of the Senate version, “I welcome the House bill, which was the product of intense negotiations.”

He said the legislation would “express solidarity with our closest allies in countering Russian aggression and holding the Kremlin accountable for their destabilizing activities.”

Senator Chuck Schumer of New York, the minority leader, said he expected this “strong” bill to reach the president’s desk promptly “on a broad bipartisan basis.”

In the House, Representative Steny H. Hoyer of Maryland, the minority whip, praised the agreement’s stipulation that “the majority and minority are able to exercise our oversight role over the administration’s implementation of sanctions.”

But Representative Nancy Pelosi of California, the Democratic leader, struck a notably different tone. In a statement, she said she was “concerned by changes insisted upon by Republicans” that would empower Republican leadership only to “originate actions in the House to prevent the Trump administration from rolling back sanctions.”

She also registered concerns about adding sanctions against North Korea to the package, questioning whether it would prompt delays in the Senate. Mr. Schumer and Mr. Cardin expressed no such concerns.

Republican leaders did not immediately release statements on Saturday.

The delays in the House became a source of deep frustration among some Russia hawks, including Senator John McCain, Republican of Arizona, before he left Washington for medical treatment for a brain tumor.

“Pass it, for Christ’s sake,” he said to his House colleagues, as the measure languished last week over technical concerns raised mostly by Republicans.

As House Republican leaders like Speaker Paul D. Ryan chafed at the suggestion that they were doing the White House’s bidding by not taking up the measure immediately, the administration sought to pressure members by insisting that the legislation would unduly hamstring the president.

Officials argued that Mr. Trump would be effectively handcuffed — deprived of the power to ease or lift the sanctions as he saw fit. The White House pushed to remove language giving Congress the ability to block such actions.