Senior US and Iranian officials are expected to meet in Oman later for direct talks amid a crisis that has raised fears of a military confrontation between the two countries.

The discussions come after a US military build-up in the Middle East in response to Iran's violent repression of nationwide anti-government protests last month, that human rights groups say killed many thousands of people.

Uncertainty over the location and scope had threatened to derail the talks, which are part of a diplomatic effort by regional mediators to de-escalate tensions.

Both countries remain far apart in their positions. The hope is that, if successful, the discussions could lead to a framework for negotiations.

The US, which is demanding Iran freezes its nuclear programme and discards its stockpile of enriched uranium, had said the talks should also involve Iran's ballistic missiles, the country's support for regional armed groups and its treatment of its citizens.

Iran, however, has said the discussions will be limited to its nuclear programme, and it is unclear if these differences have been resolved.

In recent weeks, President Donald Trump has threatened to bomb Iran if it does not reach a deal. The US has sent thousands of troops and what Trump has described as an armada to the region, including an aircraft carrier along with other warships as well as fighter jets.

Iran has vowed to respond to an attack with force, threatening to strike American military assets in the Middle East and Israel.

The Iranian delegation will be led by Foreign Minister Abbas Araghchi, while the US will be represented by special envoy Steve Witkoff and Trump's son-in-law, Jared Kushner.

This will be the first meeting involving US and Iranian officials since the war between Israel and Iran last June, when the US bombed Iran's three main nuclear facilities.

For Iran's embattled leaders, the talks could be the last chance to avert US military action that could further destabilise the regime, which analysts say is in its weakest position since it came to power following the 1979 Islamic Revolution. Trump's threats came as Iran's security forces brutally repressed large-scale demonstrations, which were triggered by a deepening economic crisis, and saw protesters calling for the end of the Islamic Republic.

The current crisis has brought back to discussions the issue of Iran's nuclear programme, which has been at the centre of a long-running dispute with the West. For decades, Iran has said its programme is for peaceful purposes, while the US and Israel have accused it of being part of an effort to develop a weapon.

Iran says it has the right to enrich uranium in its own territory and has rejected calls for its stockpile of highly enriched uranium - 400kg (880lb) - to be transferred to a third country. Officials have indicated being open to concessions, which could include the creation of a regional consortium for uranium enrichment, as proposed during talks with the US that collapsed when Israel launched its surprise war last year.

At the same time, Iran says demands to limit the country's ballistic missile programme and to end the support for proxies in the region - an alliance Tehran calls the Axis of Resistance that includes Hamas in Gaza, militias in Iraq, Hezbollah in Lebanon and the Houthis in Yemen - are unacceptable and a breach of its sovereignty.

On Tuesday, Iranian President Masoud Pezeshkian said he had instructed Araghchi to pursue fair and equitable negotiations with the US, provided that a suitable environment exists. In any case, Iran is expected to demand the lifting of sanctions that have crippled its economy. Opponents of the regime say any relief would give the clerical rulers a lifeline.

For the US, the meeting, depending on its outcome, could offer an offramp for Trump from his military threats. Regional countries are concerned that a US strike could lead to a wider conflict or long-term chaos in Iran, and have warned that air power alone will not be able to topple the Iranian leadership.