Japan had matched Spain throughout the game, playing with creativity and invention going forward and tenacity without the ball and they were five minutes away from taking the match to a penalty shootout.
After a cagey first half, Spain thought they had a great chance to go in front when referee Kevin Ortega of Peru pointed to the penalty spot after Mikel Merino went down under challenge from Maya Yoshida. But the video assistant referee ordered Ortega to go to the pitchside monitor and he saw the clear images that Yoshida had made a perfectly fair and well-timed challenge.
That overturned penalty sparked both sides into life and it was a lively second half with openings at both ends. Japan keeper Kosei Tani did well to race out quickly and smother Rafa Mir as the ball broke to him close to goal while at the other end Takefusa Kubo's blast at the near post was parried by Unai Simon.
Both teams were unable to make the most of half-chances, however, and the game followed a similar pattern into extra-time before Real Madrid forward Asensio picked the ball up in the inside right channel, glanced up and curled the ball into the far corner.
Spain are looking to repeat their gold medal success from the Barcelona Games in 1992 but will have to beat the Rio winners from five years ago.
"They are a quality side, we know that and we know that if we are going to win the gold medal we are going to have to play the best teams here," said Spain defender Eric Garcia.