WASHINGTON (Reuters) - The U.S. Senate voted almost unanimously on Thursday to slap new sanctions on Russia, putting President Donald Trump in a tough position by forcing him to take a hard line on Moscow or veto the legislation and infuriate his own Republican Party. The legislation all but dashes Trump’s hopes for warmer ties with Moscow as his administration is dogged by congressional and special counsel investigations into Russian meddling in the 2016 U.S. presidential election to sway it in Trump’s favor. Russian President Vladimir Putin, who has repeatedly denied the conclusions of U.S. intelligence agencies that Moscow interfered using cyber warfare methods, has threatened retaliation against the legislation. The Senate backed the bill, which also imposes sanctions on Iran and North Korea, by a margin of 98-2 with strong support from Trump’s fellow Republicans as well as Democrats. The bill, which includes a provision that allows Congress to stop any effort by Trump to ease existing sanctions on Russia, will now be sent to the White House for Trump to sign into law or veto. It is the first major foreign policy legislation approved by Congress under Trump, who has struggled to advance his domestic agenda despite Republicans controlling the Senate and House of Representatives. The strong bipartisan support for the bill was a sharp contrast to the bitter partisan rancor during debate over how to overhaul the U.S. healthcare system. If Trump chooses to veto it, the bill is expected to garner enough support in both chambers to override his veto and pass it into law. The sanctions measure has already passed the House of Representatives by a vote of 419-3.  Republicans and Democrats have pushed for more sanctions partly as a response to the election allegations. Trump denies any collusion between his campaign and Moscow. Republican Senator John McCain, a leading congressional voice calling for a firm line against Russia, said before the vote: “The United States of America needs to send a strong message to Vladimir Putin and any other aggressor that we will not tolerate attacks on our democracy.” Putin said Moscow would only decide on how to retaliate once it had seen the final text of the proposed law. The bill would affect a range of Russian industries and might further hurt the Russian economy, already weakened by 2014 sanctions imposed after Russia annexed Crime from Ukraine. Besides angering Moscow, the legislation has upset the European Union, which has said the new sanctions might affect its energy security and prompt it to act, too. The legislation also cracks down on Iran and North Korea  for activities including their missile development programs and human rights abuses, including seeking to punish foreign banks that do business with North Korea. It also imposes restrictions on anyone involved in Iran’s ballistic missile program and those who do business with them. The sanctions also apply to Iran’s Islamic Revolutionary Guards Corps security force. Earlier on Thursday, a senior White House aide said Trump could veto the pending legislation in order to push for a tougher deal, an idea that drew skepticism in Congress because his administration had spent weeks lobbying for a weaker bill. “He may sign the sanctions exactly the way they are or he may veto the sanctions and negotiate an even tougher deal against the Russians,” White House Communications Director Anthony Scaramucci told CNN. Earlier on Thursday, Senator Bob Corker, chairman of the Senate Foreign Relations Committee, told reporters: “I would guess that he (Trump) will sign it.” A White House official said the bill would be reviewed, “but we strongly support sanctions against all three countries.” Another White House official said it could take a couple of days before the legislation gets to Trump’s desk. Trump can impose new sanctions at any time through an executive order. “This bill doesn’t preclude him from issuing tougher sanctions. That doesn’t make any sense,” said Edward Fishman, a former State Department official during the Obama administration who worked on U.S. sanctions policy. Once Trump receives the bill, if he does not sign it, he has 10 days, excluding Sundays, before he must issue a veto and prevent the bill from becoming law automatically.  If he opts for a veto, the bill can become law anyway if two-thirds of both the House and Senate vote for an override.  Putin said on a visit to Finland on Thursday that Russia was “exercising restraint and patience, but at some moment we’ll have to retaliate. It’s impossible to endlessly tolerate this boorishness towards our country.” Putin, at a news conference with Finnish President Sauli Niinisto, also spoke about former President Barack Obama’s order last December to seize Russian diplomatic property in the United States and to expel 35 Russian diplomats. “This goes beyond all reasonable bounds,” Putin said. “And now these sanctions - they are also absolutely unlawful from the point of view of international law.” 