Substitute Alexia Putellas's 93rd-minute header deflected in off England goalkeeper Karen Bardsley to earn Spain a win in their first finals appearance in 16 years, following late drama in Linkoping.
Verónica Boquete gave Spain the perfect start with her fourth-minute goal but Eniola Aluko quickly responded. That electric start was matched by the ending, as firstly Jennifer Hermoso thought she had won it five minutes from time, before Laura Bassett's 89th-minute intervention. Spain were not to be denied, however, and join Monday's opponents France at the top of Group C.
Bassett was partnering England captain Casey Stoney in defence in the absence of the injured Sophie Bradley, and straight away they were put under pressure. Adriana fired a warning shot over the bar before Sonia's perfectly-timed ball sent Boquete clear and the captain calmly beat Bardsley.
It took England only four minutes to respond. After some neat touches the ball came to Jill Scott in midfield and in a crowded box she slipped through a pass for Aluko to finish. Now the game was truly on, and a Fara Williams long shot was tipped over by Ainhoa Tirapu while at the other end Sonia picked up a loose pass and curled an effort wide before her angled strike forced an acrobatic save from Bardsley, once based in this city with Linköpings FC.
Things calmed down after that breathless first quarter, though Boquete showed her ability again as she teed up Adriana, whose effort was sliced. Stephanie Houghton, working tirelessly on the left despite recent injury, centred but Ellen White's touch was blocked by Ruth García.
Marta Torrejón's high cross from the right deceived Bardsley with its bounce and the goalkeeper could only palm the ball to the lurking Vicky Losada but from point-blank range the substitute hit the crossbar.
England were not let off a second time, however, as an 85th-minute corner was cleared to Silvia Meseguer, whose shot deflected into the path of Hermoso to drill in. Spain held on to their lead for just four minutes after going ahead for the first time, and remarkably did so again.
Anita Asante knocked down Rachel Yankey's corner and Bassett swept into the net from close in as England looked to have salvaged a draw. It was not to be, however, as deep into added time Adrian's cross from the right was met by the head of Putellas, and the effort flicked off Bardsley and into the net to spark scenes of delight among the Spanish contingent.
Player of the match: Jennifer Hermoso