Image copyright Courtesy of Maryam Mirzakhani Image caption Prof Mirzakhani is seen as an inspiration for young female mathematicians

Maryam Mirzakhani, the first woman to receive the prestigious Fields Medal for mathematics, has died in the US.

The 40-year-old Iranian, a professor at Stanford University, had breast cancer which had spread to her bones.

Nicknamed the "Nobel Prize for Mathematics", the Fields Medal is only awarded every four years to between two and four mathematicians under 40.

It was given to Prof Mirzakhani in 2014 for her work on complex geometry and dynamical systems.

Iranian President Hassan Rouhani said Prof Mirzakhani's death caused "great sorrow," state media reported.

Foreign Minister Mohammad Javad Zarif said her death was a cause for grief for all Iranians.

"A light was turned off today. It breaks my heart... gone far too soon," US-Iranian scientist Firouz Naderi posted on Instagram.

He added in a subsequent post: "A genius? Yes. But also a daughter, a mother and a wife."

Prof Mirzakhani and her husband, Czech scientist Jan Vondrak, had one daughter.

Some social media users criticised Iranian officials for not using recent images of Prof Mirzakhani which showed her uncovered hair. Iranian women must cover their hair in line with a strict interpretation of Islamic law on modesty.

Iranian official media and politicians used older pictures in their social media tributes, which show her hair covered.

Image copyright Instagram Image caption Iranian Speaker Ali Larijani - using an older image of Prof Mirzakhani - said on Instagram that her loss "caused great regret"

Stanford University President Marc Tessier-Lavigne described Prof Mirzakhani as "a brilliant mathematical theorist and also a humble person who accepted honours only with the hope that it might encourage others to follow her path".

"Maryam is gone far too soon but her impact will live on for the thousands of women she inspired to pursue math and science," he said.

"Her contributions as both a scholar and a role model are significant and enduring and she will be dearly missed here at Stanford and around the world."

Born in 1977, Prof Mirzakhani was brought up in post-revolutionary Iran and won two gold medals in the International Mathematical Olympiad as a teenager.

She earned a PhD at Harvard University in 2004, and later worked at Princeton before securing a professorship at Stanford in 2008.

Her receipt of the Fields Medal three years ago ended a long wait for women in the mathematics community for the prize, first established in 1936.

Prof Mirzakhani was also the first Iranian to receive it.

The citation said she had made "striking and highly original contributions to geometry and dynamical systems" and that her most recent work constituted "a major advance".

Prof Dame Frances Kirwan, a member of the medal selection committee from the University of Oxford, said at the time: "I hope that this award will inspire lots more girls and young women, in this country and around the world, to believe in their own abilities and aim to be the Fields Medallists of the future."