Norway’s Filip Ingebrigtsen held on for bronze.
She said: “I could see Ayana was not going so I thought, why not? So I said, go. I am mentally strong so I knew I was capable.”
The 26-year-old has been in the spotlight since first becoming world champion aged 18 in 2009, having been scrutinised for high levels of testosterone.
Kenya’s Helen Obiri kicked away from Ethiopia’s 10,000m champion Almaz Ayana in the final 300m to claim a convincing victory in the 5,000m.