Portugal will face Giant Killers Morocco who beat Spain 3-0 in a penalty-shootout, as both sides failed to score in 120 minutes.
Luis Enrique's Spain were dominant throughout, but could not find a way through a rugged Moroccan defense.
They could have nicked it in the dying seconds of the extra time, but Pablo Sarabia's volley from a tight angle hit the post.
In the shootout, Sarabia again hit the post. Carlos Soler's tame effort was saved, and Sergio Busquets missed his spotkick. And Madrid-born Achraf Hakimi converted a Panenka to send Morocco through to the quarter-finals; their first-ever appearance at this World Cup stage.