In its first match in Group F at Mestalla, Luis Enrique's side was dominant but saw Josh King cancel out Rodrigo Moreno's opener.
Inigo Martinez needlessly gave away a penalty that Bournemouth striker King confidently stroked home to level the scores in the 76th minute.
But another error at the other end handed Spain the points, the otherwise impressive goalkeeper Rune Jarstein bringing down Alvaro Morata and Ramos converting with a Panenka.
Norway was on the back foot from the off but it took until the 16th minute for Spain to find a way through.
Jordi Alba played a one-two with Marco Asensio and the former Valencia left-back put a cross on a plate for Rodrigo to tuck home in front of his home fans.
Spain had a lucky escape when Tarik Elyounoussi somehow failed to convert a low cross from Markus Henriksen, the centre having cut out David de Gea in the hosts' goal, before the offside flag denied Alba.
Ramos sent a volley over the crossbar as Spain continued to create chances after the interval but Norway was awarded a penalty as referee Andris Treimanis adjudged Martinez to have dragged Bjorn Johnsen to the ground.
De Gea guessed correctly in diving low to his left but did not get close to King's precise spot-kick.
Morata had wasted a series of openings and missed his best chance yet when heading a Dani Ceballos cross off target, but when he raced through on goal Jarstein made a critical error.
Captain Ramos was never going to pass up the opportunity, floating his penalty into the space vacated by Jarstein to score for his fifth consecutive international appearance.