Spain's young squad got off to a high-scoring start at the World Cup, routing Costa Rica 7-0 on Wednesday.
Not long after Japan surprised Germany 2-1 in the other Group E match, Spain avoided any chance of an upset with Dani Olmo, Marco Asensio and Ferran Torres scoring a goal each in the first 31 minutes.
Torres, Gavi, Carlos Soler and Álvaro Morata added to the lead in the second half.
Olmo's goal was the 100th at World Cups for Spain, which became the sixth nation to score more than 100 times in the tournament.
It was the first time Spain has scored seven goals in a World Cup match.
With 18-year-old Gavi and 19-year-old Pedri starting, Spain became the first European nation with two teenagers in the starting lineup of a World Cup match in 60 years, according to statistics platform Opta.
Gavi then became the youngest goal scorer at the World Cup since Pelé in the 1958 final, also according to Opta.
Gavi and Pedri were among the many youngsters picked by Spain coach Luis Enrique in a revamped squad in Qatar - the third-youngest team among the 32 nations, after the United States and Ghana.
The young duo helped Spain control the pace of the match from the start at Al Thumama Stadium.
Costa Rica looked overwhelmed from the start in its third straight World Cup campaign.
It came to Qatar hoping to repeat its surprise run to the quarterfinals in 2014 in Brazil, and avoid a repeat of its participation four years ago in Russia, when it was eliminated in the group stage after not winning any matches.
Spain, which didn't get past the round of 16 in Russia, is trying to break through with a major title after making it to the final of the Nations League and the semifinals of last year's European Championship.
This year the team also qualified for the Final Four of the Nations League for a second straight time.
Spain's last major triumph came at Euro 2012, two years after it won its lone World Cup title in South Africa.
Only five countries have scored more goals than Spain at the World Cup - Brazil, Germany, Argentina, Italy and France.