Congrats to #MaryamMirzakhani on becoming the first ever woman to win the #FieldsMedal, making us Iranians very proud pic.twitter.com/oVL98NRdVF — Hassan Rouhani (@HassanRouhani) August 13, 2014

"Congrats." So reads the message from Iranian President Hassan Rouhani to Maryam Mirzakhani, the first woman to ever win the Fields Medal, which is something like the Nobel Prize for mathematics.

Mirzakhani, a Stanford University professor, happens to have been born and raised in Iran. In celebrating her win, Rouhani tweeted two photos: one showing Mirzakhani with a headscarf (as required by Iranian law) and one without it.

Mirzakhani came to the United States in 1999 to study at Harvard, but she first excelled in Iran: She won gold medals in the 1994 and 1995 International Math Olympiads, and she earned her undergraduate degree in mathematics at Sharif University in Tehran.

"I should say that the education system in Iran is not the way people might imagine here," she told Clay Mathematics Institute. "As a graduate student at Harvard, I had to explain quite a few times that I was allowed to attend a university as a woman in Iran."

Being a highly educated Iranian woman is actually quite normal. Women outnumber men in Iranian universities, a trend that started in 2001.

But it hasn't been easy for women pursuing higher education in Iran. In 2012, 36 universities banned women from 77 majors, including nuclear physics, oil engineering and counseling. The multi-campus Oil Industry University closed its doors entirely to women.

One of the explanations for the ban: Iranian women holding those degrees have trouble finding employment. For instance, University of Isfahan's chancellor said in 2012 that almost all of the school's female mine-engineering graduates can't get jobs. "We do not need female students at all," he told the state news agency Mehr, according to Bloomberg.

Critics of the policy, such as Nobel Peace Prize winner Shirin Ebadi, have said that officials actually want to bring the share of women in universities below 50 percent. The 2012 ban came after an unsuccessful attempt to completely segregate men and women on campuses.

At the same time, highly educated women (and men, for that matter) have been leaving Iran in droves in search of better economic opportunity, academic freedom and improved quality of life. The country has suffered from a national "brain drain" because of it; 300,000 Iranians left from 2009 to 2013, the World Bank estimates, and the number of Iranians in American universities is on the rise.

Rouhani has been under pressure to reverse this trend and keep educated people in Iran. People such as Mirzakhani, who, the president tweeted, has made "us Iranians very proud."