Scotland needed just a point to qualify for next summer's European Championship and thought that they had made the crucial breakthrough on the hour through Scott McTominay, but the midfielder's excellent free kick was disallowed for an offside on Jack Hendry.
Spain then scored 14 minutes later, with Morata heading a cross from Jesus Navas into the back of the net from close range, before Sancet doubled the home side's advantage in the 87th minute.
Scotland, who will face Georgia in their next qualifier on November 16, remain top of Group A on 15 points, three points ahead of second-placed Spain, who have a game in hand.
Spain should have taken the lead inside the opening two minutes, with Morata picking out Ferran Torres's run with an excellent pass, but the latter placed his effort just wide of the post.
La Roja had another opportunity in the fifth minute, with Morata meeting a corner at the far post, but the striker could only head wide of the target, with Scotland receiving another let-off in the early exchanges.
Spain were unsurprisingly dominating the ball, and Mikel Oyarzabal was next to try his luck in the 20th minute, lifting one over the crossbar after smart work from Alejandro Balde.
The home side then struck the post in the 34th minute, with Mikel Merino's crisp strike hitting the woodwork when Scotland goalkeeper Angus Gunn was well-beaten between the sticks.
Spain had the ball in the back of the net in the 38th minute, with Morata poking a low Dani Carvajal cross past Gunn, but the offside flag came to the away side's rescue, and it was confirmed as the right decision.
Scotland were forced into a change late in the first period, with Andrew Robertson picking up an arm injury, but Steve Clarke's side were able to get to the break with the scores level at 0-0 despite finding it difficult to get going for much of the opening half of action.
Bryan Zaragoza, who was one of two half-time changes for Spain, fired a long-range effort over the Scotland crossbar in the early stages of the second period.
The away side's first serious opening of the match came in the 53rd minute, with John McGinn finding Ryan Christie with a clever pass, but the attacker just lost his footing at the vital moment.
Morata then fired over the crossbar from a deflected Carvajal cross, before Scotland thought that they had taken the lead through McTominay.
There were jubilant scenes in the away end when McTominay found the back of the net with a free kick from what looked to be an impossible angle, but it was disallowed by the referee following a VAR check, with Hendry penalised for an offside just in front of goalkeeper Unai Simon.
Spain then made the breakthrough in the 73rd minute through Morata, who headed a cross from substitute Navas into the back of the net at the front post.
The home side doubled their advantage in the 86th minute, as a mistake from Hickey allowed Joselu to cross into Sancet, who managed to bundle the ball home from close range.
Spain will now head to Norway, who are third in the section on 10 points, on Sunday knowing that a win would move them to the top of Group A ahead of Scotland on the same number of matches.
If Norway fail to beat Spain, then Scotland's spot at Euro 2024 will be confirmed.