The Senate on Thursday approved sweeping sanctions against Russia, forcing President Trump to decide whether to accept a tougher line against Moscow or issue a politically explosive veto amid investigations into ties between his presidential campaign and Russian officials.

The Senate vote, 98 to 2, followed the passage of a House bill this week to punish Russia, Iran and North Korea for various violations by each of the three American adversaries. In effect, the measure would sharply limit Mr. Trump’s ability to suspend or lift sanctions on Russia — handcuffing a sitting president just six months into his term with the nearly unanimous support of a Republican-led Congress.

The Trump administration has opposed the sanctions against Russia, arguing that it needs flexibility to pursue a more collaborative diplomacy with a country that, by American intelligence consensus, interfered in last year’s presidential election. But now the president faces a decision he had hoped to avoid, even though the administration supports sanctions against Iran and North Korea.

White House aides have acknowledged privately that a veto would be politically awkward, at best, for Mr. Trump to justify during the continuing investigations into whether his campaign colluded with Russia.