**Maryam Mirzakhani, an Iranian mathematician who was the only woman ever to win a Fields Medal, the most prestigious honor in mathematics, died on Friday. She was 40.**

The cause was breast cancer, said Stanford University, where she was a professor. The university did not say where she died.

Her death is “a big loss and shock to the mathematical community worldwide,” said Peter C. Sarnak, a mathematician at Princeton University and the Institute for Advanced Study.

The Fields Medal, established in 1936, is often described as the Nobel Prize of mathematics. But unlike the Nobels, the Fields are bestowed only on people aged 40 or younger, not just to honor their accomplishments but also to predict future mathematical triumphs. The Fields are awarded every four years, with up to four mathematicians chosen at a time.

“She was in the midst of doing fantastic work,” Dr. Sarnak said. “Not only did she solve many problems; in solving problems, she developed tools that are now the bread and butter of people working in the field.”

Dr. Mirzakhani was one of four Fields winners in 2014, at the International Congress of Mathematicians in South Korea. Until then, all 52 recipients had been men. She was also the only Iranian ever to win the award.

President Hassan Rouhani of Iran released a statement expressing “great grief and sorrow.”

He wrote, “The unparalleled excellence of the creative scientist and humble person that echoed Iran’s name in scientific circles around the world was a turning point in introducing Iranian women and youth on their way to conquer the summits of pride and various international stages.”

Dr. Mirzakhani’s mathematics looked at the interplay of dynamics and geometry, in some ways a more complicated version of billiards, with balls bouncing from one side to another of a rectangular billiards table eternally.

A ball’s path can sometimes be a repeating pattern. A simple example is a ball that hits a side at a right angle. It would then bounce back and forth in a line forever, never moving to any other part of the table. But if a ball bounced at an angle, its trajectory would be more intricate, often covering the entire table.

“You want to see the trajectory of the ball,” Dr. Mirzakhani explained in a video produced by the Simons Foundation and the International Mathematical Union to profile the 2014 Fields winners. “Would it cover all your billiard table? Can you find closed billiards paths? And interestingly enough, this is an open question in general.”