His position has been taken by Revolutionary Guards general Ali Akbar Ahmadian.
“While appreciating the 10-year efforts of Admiral Ali Shamkhani as the secretary of the Supreme National Security Council, Ayatollah Dr Seyyed Ebrahim Raisi appointed Dr Ali Akbar Ahmadian to this position,” the president's website said.
Dr Ahmadian headed the Revolutionary Guards' “strategic centre” before assuming his new position, it said.
Mr Shamkhani was a key figure in the deal that normalised ties between Iran and Saudi Arabia in March, ending seven years of rivalry.
He was photographed shaking hands with Saudi national security adviser Musaad Al Aiban during a closed meeting in Beijing.
Mr Shamkhani's role in politics began in the 1990s.
"Ali Shamkhani was really significant for a few reasons," said Arash Azizi, a historian at New York University, who published a book on the former head of Iran’s Islamic Revolutionary Guard Corps, Maj Gen Qassem Suleimani.
"He was the highest ranking security official of the regime in recent years to be coming from a non-hardliner, can even say a centrist, background because he was defence minister under the reformist government of president Mohammad Khatami and he was in many ways seen close to centrist president Hassan Rouhani."
Mr Azizi said the circumstances surrounding Mr Shamkhani's replacement were not straightforward. Mr Shamkhani had posted two lines from a poem on Twitter shortly before the Security Council's agency, Nour, announced that he was being replaced.
It is by Mohtasham Kashani, a Shiite Iranian poet from the 16th century.
"He was pushed aside in a strange and very unusual way. The lines Mr Shamkhani chose speak of 'words spoken in secret'. 'He spoke in code and gestured and left'," Mr Azizi said the poem read.
"It's thus clear what Shamkhani is saying: that he has to be pushed aside for reasons that can't be divulged."
However, Iran expert Mohamad Al Zghool believes Mr Shamkhani's replacement says more about the reasoning behind the move.
"Ebrahim Raisi considers Shamkhani to be a reformist, even though he is independent and does not have a political affiliation," he said. "As a person, Shamkhani's direct connection is with the supreme leader. And the IRGC's qualms with Shamkhani lie in his endorsement for stronger Iranian ties with China, whereas they prefer stronger economic, military and geopolitical relations with Russia in the east."
Mr Zghool the appointment of Dr Ahmadian could indicate a new direction in Russia-Iran ties.
"This does not mean that ties with China are going to become obsolete or frozen, but the priorities are likely to be in favour of a stronger relationship with Russia," he said.
Additionally, Mr Shamkhani's former aide, British-Iranian citizen Ali Reza Akbari, was sentenced to death this year on charges of spying.