Image copyright AFP/GEtty Image caption Will Ayatollah Khamenei be this friendly given Mr Abe's close US ties?

Japanese Prime Minister Shinzo Abe has called on Iran to play a role in ensuring peace in the Middle East.

Mr Abe is in Tehran, hoping to ease tensions between Iran and the US.

He is the first Japanese prime minister to visit Iran in four decades and is due to meet Supreme Leader Ayatollah Khamenei.

Iran has been angered by sweeping US sanctions imposed after President Trump abandoned a deal in which the Iranians agreed to curb their nuclear programme.

What happened?

Dozens of hard-line students protested outside Tehran's Mehrabad International Airport over Mr Abe's efforts to ease tensions between the US and Iran.

Mr Abe was greeted by Iranian president Hassan Rouhani and they held talks, before giving a joint press conference where the Japanese leader called for calm in the region.

"Amid rising tension, it is essential for Iran to play a constructive role in strengthening peace and stability in the Middle East, so that this region won't be destabilised further or accidental clashes won't happen," Mr Abe said.

Mr Rouhani said that Iran did not want conflict with the US but that it would give "a crushing response" if it were attacked.

Why has Abe gone to Iran?

Officially, Japan and Iran are marking the 90th anniversary of their diplomatic relationship this year.

Much more significant is that the trip comes shortly after US President Donald Trump made a state visit to Japan, a key US ally.

US relations with Iran nosedived over Washington's withdrawal from the 2015 nuclear deal over Iran's nuclear programme.

Tensions escalated further when the US sent an aircraft carrier to the region, raising fears of a military confrontation.

Image copyright Getty Images Image caption Mr Trump and Mr Abe met in Japan earlier this month

There are hopes that Mr Abe might be able to engage in some diplomacy between the two sides, dialling down tensions and getting them to talk to each other.

Just one day before heading off, the Japanese prime minister spoke to Mr Trump on the phone and exchanged views on Iran, a spokesperson for Mr Abe told reporters on Tuesday.

What's the Iran nuclear deal?

Essentially, in 2015 Iran agreed to limit its nuclear programme in return for sanctions being lifted.

The deal was done under the Obama administration though, and Mr Trump withdrew from it last year.

The US reinstated unilateral sanctions while other signatories to the 2015 deal - like the EU, Russia and China - still hope to keep the agreement alive.

Media playback is unsupported on your device Media caption The BBC’s Paul Adams looks at the recent developments behind the US-Iran tensions

In retaliation for sanctions reinstated by the US, Iran last month announced it would suspend some commitments.

On Tuesday, the International Atomic Energy Agency (IAEA) said Iran was increasing its production of enriched uranium though it's not clear when it will reach a limit set under the 2015 deal.

Why does it matter to Japan?

Tokyo has never been part of the Iran agreement but that does not mean it isn't affected.

Japan used to import oil from Iran. Following fresh US sanctions it has bowed to Washington and stopped those imports.

"Japan supports the 2015 agreement and is unhappy that the US pulled the plug and thinks it's a really big mistake," explains Professor Jeff Kingston, director of Asian Studies at Tokyo's Temple University.

"But it has no real say in the matter, so when US imposed sanctions it's not surprising that Japan followed."

Image copyright Reuters Image caption Japan has tried to maintain good relations with all of the Middle East

While Tokyo can do without Iranian oil for now, any conflict in the Middle East would probably drive up oil prices and that would naturally affect Japan a lot.

Since the end of World War Two, Japan has always pursued what's dubbed an omni-directional foreign policy.

What that means for the Middle East is that Tokyo is trying to talk to everybody, stay friends with everyone, to make sure it can still get oil.

Can Japan mediate between the US and Iran?

Observers doubt that Mr Abe has much leverage to make a difference.

"My take is that the chances of brokering a 'deal' between Iran and the USA are close to zero," Professor Robert Dujarric, head of the Institute of Contemporary Asian Studies in Tokyo, told the BBC.

While unlike the West, Japan is free of historical or religious baggage when it comes to talking to Iran, "Mr Abe will still not be seen as an honest broker by Tehran," explains Mr Kingston.

A good mediator would be someone seen as impartial by both sides, but Mr Abe and Mr Trump have just met in Japan and for long have prided themselves on their good friendship.

Image copyright AFP Image caption Mr Trump and Mr Abe are friends in politics and on the golf course

"Given his close ties with Washington, why would Iran accept that Mr Abe is objective?" Mr Kingston says. "Iran will see Japan as clearly tied to Trump and the US alliance."

Most observers therefore expect very little from the trip and government officials have also been dialling down expectations.

On Tuesday, Japanese media cited unnamed government sources saying Mr Abe was not going as a mediator and did not have a quick fix to end the crisis.

Will it boost Abe's image back home?

Most analysts see the real purpose of the trip in his domestic agenda.

It might not yield much in terms of US-Iran tensions, "but it's good for Mr Abe," explains Mr Dujarric. "It shows the voter that he is a world statesman."

And that is important for the Japanese prime minister. Elections for the upper house are coming up in July and there is speculation Mr Abe might call a snap general election if he is confident he will win it.

"The international diplomacy is part of the art and theatre of politics for Mr Abe," says Mr Kingston. "He is good at that."

Mr Abe came to office on a promise to restore Japan amid a feeling that the country's best years might be behind it.

As prime minister, he portrays himself as reviving the economy and as boosting the country's standing on the international stage.

Image copyright AFP Image caption Shinzo Abe sees himself as restoring Japan to strength

Yet so far, his international diplomatic activity has yielded little results, experts say.

Tokyo has been sidelines in the negotiation with North Korea while talks with Russia over a group of disputed islands have also stalled.

But given that all these diplomatic issues - including the Middle East tensions - are notoriously difficult, there's actually very little risk or downside for the Japanese prime minister, observers say.

"He won't be seen as failing to resolve them but rather as trying to do something," says Mr Kingston.

"Foreign policy doesn't win elections, but it helps to make Mr Abe look more substantial than he is."

Reporting by the BBC's Andreas Illmer.