Stoch led by almost three points after the first jump, but then a huge leap from 41-year-old Kasai in the second round mean that the Pole found himself suddenly under pressure.
However, he kept his nerve, doing just enough to maintain a lead of 1.3 points and secure the gold medal, to double his tally at Sochi 2014 and add to the large hill world title he won last year.
Slovenia's Peter Prevc took bronze after himself producing a huge leap of over 140 metres in the second round.
“I did such a big mistake in the second round. I don't know how I jumped so far,” said a bemused Stoch as he tried to absorb the magnitude of his achievement.
“I was too aggressive. That's why I flew so far, but hey… That's why I won!”
Kasai, who had also won silver in Lillehammer a full 20 years earlier – thus equalling the record for the longest time between two Olympic medals – said that the result made up for missing out on a the podium in the normal hill.
“I took the medal that I didn't take in the normal hill. Then I felt regret and now I feel happy,” said the 41-year old.
Meanwhile, Prevc, who had already won silver on the normal hill, said his focus now was the team event which sees the podium places decided on 18 February.
“There will be no celebrations, at least until Monday, then we will see," said the Slovenian.
Stoch had begun the competition as hot favourite having won the world title in March 2013, not to mention gold on the normal hill. And following the first round he appeared unbeatable after sailing out to 139m.
Kasai had matched that distance in the first round but with his wind advantage and not being scored as highly by the judges, he found himself 2.8 points behind going into the second jump.
Germany's Severin Freund was only 0.4 behind Kasai and also seemed in with a chance, while at that stage Prevc was almost six points off a medal.
The Slovenian sailed the furthest in the second jump to leapfrog Freund. But the real drama was still to come.
Kasai landed a huge jump and looked to have maybe done enough to snatch the gold, only for Stoch to respond to get himself over the line.