Japan, beaten by the Koreans in 1998, trailed 26-17 with two minutes left to play but pulled the game out of the fire when Akihito Yamada scored in the corner right at the death after Hiroki Yoshida's conversion miss following Masahiro Tsuiki's try two minutes earlier looked to have cost them the gold.
"It was amazing, unbelievable. The boys never gave up and showed a lot of heart which is why we won the gold," beamed Japan coach Jun Sano.
Meanwhile China came from 12-7 down in the final few minutes to defeat Chinese Taipei 19-12 in the bronze medal match.
Lu Zhuan sparked the comeback with a blistering 60 metre run and although skipper Zhang Zhqiang missed the conversion China scored a try right at the end after Li Yang had intercepted Chang Wei Cheng's misplaced pass.