Both men jumped 139 metres in the first round. Kasai jumped 133.5 metres in the second round, and although Stoch actually leapt a metre less with the final effort of the event, he squeaked home thanks to slightly better style marks.
Stoch said he had taken a big risk by going all out in the second round.
"I made such a big mistake ... I don't know how I jumped so far. I was too aggressive. That's why I flew so far, but hey, what the heck? That's why I won," he told reporters.
The 26-year-old world number one, who easily won the normal hill event on Sunday, finished with 278.7 points, just ahead of Kasai on 277.4 points. It was the Japanese athlete's first individual jumping medal in his seventh Olympics.
There was not a hint of frustration at narrowly missing out on gold from Kansai, who jumped up and down on the podium and punched the air in delight.
Slovenia's Peter Prevc won a bronze, adding to the silver he won on the normal hill.
The competition was hampered by strong winds that forced the cancellation of the trial round. As the jumps became dangerously long in the final round, officials lowered the position of the starting gate.
The capacity crowd cheered wildly when Russia's Dimitry Vassiliev landed the longest jump of all with 144.5 metres in the second round, but he slipped on landing and received poor style marks.
Defending champion Simon Ammann of Switzerland, who has had trouble with his take-offs all week, landed two average jumps and ended 23rd.
Ammann won both hills in 2002 as well as 2010. The first man to do so was Matti Nykanen of Finland in 1988.