Gasol, the 2.16-meter (7-foot-1) center from the Memphis Grizzlies, played most of the game, scoring the game's last basket at the final buzzer.
Spain (5-0), which was fifth in the 2002 worlds and fourth in the Athens Olympics, finished atop its six-team group and will open the second round this weekend in Saitama.
Gasol had eight points and six rebounds as Spain dominated inside and took a 47-27 halftime lead over Japan (1-4), the AP says.
Spain scored the first 19 points of the second half, nine by Juan Carlos Navarro, to go up 66-27 with 3:43 left in the third quarter. Japan's first points of the second half didn't go through the basket as Daiji Yamada was credited with the basket on a goaltending call against Jorge Garbajosa.
The lead was 78-36 after three quarters and when it reached 50, three Spanish starters were still in the game.
Navarro finished with 18 points and Alex Mumbru added 13 for Spain.
Takehiko Orimo had 13 points for Japan, which appeared on its way to advancing to the second round on Wednesday night. The host country had an 18-point halftime lead over New Zealand, but wound up losing 60-57.
Even a win over Spain wouldn't have helped Japan move on since New Zealand (2-3) beat Panama earlier Thursday and Japan would have lost the head-to-head tiebreaker.