Spain doubled the gap in the 21st minute as Marco Asensio fired with his left-foot without trapping the ball. Jordi Alba assisted from the left flank.
Alba was fouled in the box, so Spain were awarded a penalty.
Ferran Torres scored from the white spot to make it 3-0 about 10 minutes later.
Torres was again on the scoresheet. In minute 54, he put the ball into the Costa Rica net after making a standing tackle near the goal.
In the 74th minute, Spain youngster Gavi made it 5-0, kicking the ball with the outside of his right foot, followed by another goal in minute 90, this time from Carlos Soler.
Spain did not stop here, as Alvaro Morata finished in the area two minutes later after a show of teamwork, naming the result.
So, the 2010 world champions Spain secured the 7-0 win for a superb start to their Qatar campaign, topping Group E on goal average.
Japan, who stunned Germany 2-1 earlier on Wednesday, are second in the standings.
Germany and Costa Rica are the two lowest teams in the group.
In the next fixture, Spain will face Germany on Nov. 27 at the Al Bayt Stadium.
Only the best two teams in each group will reach the last 16 after the third matches.
Source: Anadolu Agency