The Spain striker controlled a cross with one deft touch and then sent a rising shot past goalkeeper Dominik Livakovic for his second goal of the tournament.
Oyarzabal doubled the lead three minutes later, receiving a pass in the middle of the area and holding off a defender before scoring.
Morata had received a torrent of online abuse — including death threats — after a string of misses during the group stage. But his fierce finish from a tight angle proved decisive on Monday.
"I don't think there's any coach in the world who wouldn't admire a player like Morata," Spain coach Luis Enrique said. "He dominates in the air, he scores goals, he is physically powerful. He is a striker we should really value."
Spain had been knocked out in the round of 16 in its previous two tournaments but netted five goals for a second straight game after a slow start with two draws. The Spanish will play either France or Switzerland in the quarterfinals on Friday in St. Petersburg.
Croatia netted three goals for a second straight game but fell well short of replicating its feat of reaching the World Cup final in 2018.
"At the start of extra time we had them on the ropes but we failed to score from two good chances," Croatia captain Luka Modric said. "Then the game turned around and we didn't have the strength to come back."
Not for a second time, anyway.
Spain had led 3-1 in the 85th minute but Mislav Orsic pulled one back after a goalmouth scramble and Pasalic equalised with a header in injury time.
Spain had dominated the first 20 minutes but goalkeeper Unai Simon was at fault for his team's early deficit after a massive blunder when he failed to control a long back pass. The ball bounced over Simon's foot and trickled into the net behind him.
"We know that's football and that those things happen," Spain captain Sergio Busquets said. "The most important thing is to pick yourself up and show a strong mentality. And I think both Unai and the whole team did that today."
Spain quickly recovered and Pablo Sarabia equalised in the 38th. Right back Cesar Azpilicueta then made it 2-1 with a header in the 57th and Ferran Torres doubled the lead when he finished off a quick counterattack with a low shot past Livakovic in the 77th.
It looked like Spain was heading for an easy win before Croatia fought back.
"Boy, we had to suffer there," Azpilicueta said. "It wasn't great to be scored against twice late in normal time, but we were the better team in extra time and we deserve to go through."
Croatia's late surge allowed both Morata and Simon to redeem themselves.
The goalkeeper made a crucial save to deny Andrej Kramaric at the start of extra time, then got up and punched the air in celebration.
"I think that when we missed that chance at 3-3 in extra time, that was the determining factor," Croatia coach Zlatko Dalic said. "I think if we had scored a goal it would have been completely different."
Simon also made a big stop at 3-2 when he got down quickly to make a one-handed save on Josko Gvardiol's shot from just outside the box.
"We have complete confidence in (Simon)," Busquets said. "He was unlucky with that own-goal but Unai has a very laid-back mentality. He's very ambitious at the same time and I think he showed that with his reaction, and with the saves he made."