The 27-year-old produced a devastating burst down the back straight to leave defending champion Almaz Ayana trailing and went on to win in a time of 14min 34.86sec.
Ayana, who had won the 10,000m gold in what was her first race of the season, took silver for Ethiopia in 14:40.35 with the Netherlands Sifan Hassan finishing third in 14:42.73.
Obiri said that she gained confidence as Ayana failed to press the accelerator and try and shake her off.
“I was telling myself to go,” 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.
“When I crossed the line I was extremely happy, and just wanted to celebrate. All my emotion came out. I wanted the 5000m gold a lot.”
Ayana had decided to inject some much-needed zip into the pace with nine laps to run and only Obiri was able to match her.
The field was suddenly splintered with Hassan, also fom Ethiopia but who came to the Netherlands as a refugee aged 15, leading a group of five contesting the minor medal.
Ayana was unable to burn off Obiri as she had done her rivals in the 10,000m — which she won by over 46sec — with the Kenyan content to let her 25-year-old rival do all the pace-setting.
Her strategy paid off perfectly as heading into the final lap she moved up onto Ayana’s shoulder and then delivered her coup de grace.
Ayana said what she had done in London was even better than her winning the 10,000m in Rio.
“It was a difficult race,” said Ayana. “I am better at leading it to get the win rather than challenging in a final sprint. It was difficult to push Hellen (Obiri) through to the finish line.
“Compared to Rio this is a bigger achievement,” she said.
“I’ve had many injuries this year so I am very happy with two medals.”
Ayana said that she had paid for her astonishing victory in the 10,000m and had run through the pain barrier.
“I have been injured for the whole season and haven’t been able to get over it.
“The pain came back after the 10,000m. I did my best today but Hellen was too good at finishing. It was all I could today.”