By Jon Leyne
BBC News, Tehran
Ali Larijani's resignation is a complete surprise, and very significant.
Larijani's resignation removes a force for compromise
As Iran's chief nuclear negotiator, he has been a key figure in attempts to broker a compromise with the West over Iran's nuclear programme. His departure could be the start of a major shift in policy.
It is an open secret in Tehran that Mr Larijani has had big differences with President Mahmoud Ahmadinejad over how to proceed over the nuclear programme.
Like almost everyone in Iran, Mr Larijani supports the programme.
He is certainly no "liberal", even in Iranian terms. He stood for president at the last election, a candidate supported by the Revolutionary Guards, as was Mr Ahmadinejad. He is often labelled a "conservative".
But Mr Larijani has been much more strongly in favour of negotiations over the nuclear issue than the president.
By contrast, President Ahmadinejad announced at the United Nations that the "case was closed".
The process of negotiating a diplomatic solution to the nuclear issue was always going to be difficult. Now it is going to be harder still
While he has said he is willing to talk, he is not willing to give ground on the crucial issue of the programme to enrich uranium, which the West says it fears could eventually be used to make a nuclear bomb.
Without compromise on that programme, any negotiations are almost certainly doomed to failure.
The issue came to a head after Russia's President Vladimir Putin presented a new compromise on the nuclear stand-off when he visited Tehran on Tuesday.
Ali Larijani said the ideas were worth considering - Mr Ahmadinejad rejected the ideas out of hand. In fact, Mr Ahmadinejad denied that any proposals had even been offered by the Russian leader.
The Iranian government has been keen to stress that this does not mean the end of talks. A new round of discussions with the EU envoy Javier Solana will go ahead on Tuesday as planned.
The Iranian delegation will be led by Mr Larijani's successor. He is Saeed Jalili, a deputy foreign minister who is a close ally of President Ahmadinejad. Dr Jalili travelled with the president, for example, on his recent trip to New York, and was very much his right-hand man.
So this means that hardliners around the president are consolidating power. As has happened across the government over the last couple of years, those who disagree with him are being dramatically sidelined.
It also shows, once again, Supreme Leader Ayatollah Ali Khamenei siding with Mr Ahmadinejad in the complex internal battle for power that so often marks Iranian politics.
That has happened despite the fact that initial reports here suggested Ayatollah Khamenei also promised to give serious consideration to Mr Putin's recent proposals.
This change in personnel does not mean any end to talks over the nuclear issue. Iran has every interest in keeping negotiations going, even if it is not prepared to compromise.
But the process of negotiating a diplomatic solution to the nuclear issue was always going to be difficult. Now it is going to be harder still.