It was a comfortable win for the European champions, who took the lead just before the midway point in the half, when Lozano’s curling right-foot shot took a wicked deflection on its way past Rabie Zaari.
There might have been an element of luck on that occasion, but there was no good fortune required two minutes later, when Lozano sent an unstoppable drive into the roof of the net from a short free-kick by Torras.
It looked to be all over bar the shouting when Lin set up Borja for a routine finish a minute before the break, but Morocco made a game of it in the second half and pulled a goal back with Mohamed Talibi bundling the ball over the line following a penalty box scramble.
Spain soon re-established their lead with another fine goal though, Torras working an opportunity on the left and crossing for Fernandao to chest the ball into the net. And salt was applied to Moroccan wounds when they conceded a fifth goal as the final minutes ticked down when Alvaro’s deflected shot trickled agonisingly over the line.
"We know that Spain are better and stronger than us. But we played a very good match and fought hard all the way through. We didn’t let them settle into their unique style of play," Hicham Dguig, Morocco coach.
"I think we gave a very good performance and showed a lot of intelligence, controlling the pace of the game like we always do. The team is playing better and better, and we are improving every day," Venancio Lopez, Spain coach.