The Manchester United midfielder – who also grabbed a brace in Sunday's (AEDT) 3-0 win over Cyprus – got Scotland off to a flying start as his early strike deflected in off visiting defender Inigo Martinez.
While Spain enjoyed plenty of possession, Luis de la Fuente's visitors were unable to respond after McTominay doubled Scotland's lead, lashing home following excellent work from Kieran Tierney.
The result moves Scotland three points clear of Spain at the top of Group A, while De la Fuente has plenty of work to do following his first defeat since replacing Luis Enrique after the World Cup.
Scotland sent the home crowd into raptures seven minutes in as Andy Robertson capitalised on Pedro Porro's slip to find McTominay, who saw his left-footed effort deflect past Kepa Arrizabalaga.
The host almost scored a second as Ryan Christie prodded wide from the edge of the area, though it soon had the woodwork to thank as Joselu's header rattled the crossbar at the other end.
Rodri nodded narrowly over as Spain dominated possession, but Lyndon Dykes missed a great chance to double Scotland's lead when he chipped over on the stroke of half-time.
The host did not need long to score a second after the interval, however, McTominay firing into the bottom-left corner after David Garcia failed to cut out Tierney's left-wing cross 51 minutes in.
Substitute Iago Aspas lifted over from Nico Williams' driven cross as the agitated visitors threw men forwards, with Scotland holding firm to record a statement result in the battle to reach next year's tournament in Germany.