The US Senate in Congress has voted nearly unanimously to impose new sanctions against Iran and Russia, setting up a possible confrontation with the administration of President Donald Trump as it attempts to improve relations with Moscow.

The 100-member Senate backed the measure on Thursday by a margin of 98-2. Senators Rand Paul and Bernie Sanders were the only two "no" votes.

In order for the bill to become law, it must still pass the US House of Representatives and be signed by Trump. House aides said they expected the lower chamber in Congress to begin debating the measure in the coming weeks, although they could not predict when it might face a final vote.

The bill includes new sanctions on Iran over its ballistic missile program and “continued support for terrorism.”

The anti-Iran sanctions come following two sets of sanctions that were rolled out in February and May by the US Treasury Department over Iran's missile program.

A day earlier on Wednesday, the Senate added another set of sanctions on Russia for meddling in last year’s US election, its reunification with Crimea and support for Syria's government in that country's six-year-long conflict.

Read more:

Trump has been a staunch supporter of improving relations with the United States’ former Cold War foe.

The intelligence community, however, has concluded that Russia played a role in the presidential election held last November.

Trump's secretary of state, Rex Tillerson, had questioned the legislation in testimony in the House of Representatives on Wednesday.

"I would urge Congress to ensure any legislation allows the president to have the flexibility to adjust sanctions to meet the needs of what is always an evolving diplomatic situation," he told the House Foreign Affairs Committee.