Zinedine Zidane made seven changes to the side that drew 2-2 against Barcelona in El Clasico last Sunday as injuries, suspensions and a need to rotate saw Cristiano Ronaldo, Gareth Bale, Toni Kroos and Luka Modric sit out, with Sevilla taking full advantage with a little help from their former player Ramos.
Although Madrid were afforded plenty of the ball, they were not very effective and found themselves trailing 26 minutes in – Wissam Ben Yedder scoring his first LaLiga goal since February with aplomb.
Madrid's response lacked urgency and Sevilla remained the brighter going forward, eventually extending their lead through Miguel Layun's fine finish right before the interval.
Ramos wasted a chance to get the visitors back in it when his penalty come back off the crossbar, and things got even worse for the centre-back – much to the delight of the home fans – when he turned into his own net with six minutes remaining.
Substitute Borja Mayoral pulled one back before Ramos converted from the spot at the second attempt deep into second-half stoppage-time, but Sevilla held on for three points that take them into the final Europa League spot, while Zidane's side remain three adrift of second-place Atletico Madrid.
Zidane's much-changed team dictated the tempo for most of the first half, with Sevilla's set-up focusing on the pace available to them on the break.
But for all their possession, Madrid struggled to craft goalscoring opportunities and Sevilla nearly broke the deadlock 12 minutes in – Franco Vazquez's first-time effort was deflected wide by Ramos.
The former Sevilla man was helpless 14 minutes later, though. Nico Pareja's long ball from the back was flicked on by Luis Muriel to Ben Yedder, and he held off Ramos before coolly slotting through Kiko Casilla's legs.
Sevilla doubled their lead on the stroke of half-time – Steven N'Zonzi showing great awareness to tee up Layun after having a shot blocked, with the Mexican calmly finding the top-right corner.
A clumsy Franco Vazquez challenge on Lucas Vazquez gave Madrid the chance to pull one back from the spot before the hour mark, but Ramos smashed his effort against the bar.
Sevilla were not made to rue missing further chances after that, as Gabriel Mercado marched into the area in the 84th minute and saw his low cross deflected beyond Casilla by Ramos.
Mayoral - who came on for Dani Ceballos with 20 minutes remaining - got Madrid on the scoresheet when he met Marco Asensio's cross with a brilliant header into the bottom-left corner.
The visitors were awarded another penalty when Mercado was adjudged to have shoved Theo Hernandez inside the box, and Ramos fired home in the 95th minute.
It was too little too late for Madrid, though, meaning they now face an uphill battle to finish second.