Los Rojiblancos moved into a Europa League spot thanks to their latest success against Madrid, winning this home fixture for a fifth time in the last six seasons.
Hope was restored late on as substitute Borja Mayoral found a way through and Ramos had better luck from his second spot kick, but a below-par Madrid could not fully recover and were defeated away from home in La Liga for just the third time this season.
Hopes of clawing back the deficit on their city rivals took a dent 26 minutes in, however, as a punt forward skimmed the head of Luis Muriel and was converted through the legs of Kiko Casilla by Ben Yedder.
Sevilla had been the better side in the opening quarter of the match, with Franco Vazquez sending a shot over the bar from the edge of the box and seeing another blocked by Ramos.
Real, whose only on-target attempt in the first half came from a Casemiro free kick up and over the wall, were struggling to really get going without a number of their star names in the squad.
Los Rojiblancos were closing in on a second before the interval and, two minutes after Nacho got back to clear a ricocheted block off the line, Layun popped up with a rare goal.
A mixture of good fortune and poor defending allowed Steven N'Zonzi to square the ball to an unmarked Layun, who blasted it past Casilla.
Lucas Vazquez and Ramos got shots away early in the second half as Madrid attempted to find a route back into the game, and they were granted a glorious chance to do so from 12 yards.
After surviving a scare at one end when the ball was again scrambled off the line, Real got forward and won a penalty through Franco Vazquez's challenge on namesake Lucas, but Ramos thumped the resulting spot kick against the crossbar.
Muriel was then denied by Casilla from a one-on-one, while Karim Benzema - stuck on five league goals for the campaign - wasted a good chance from inside the box 14 minutes from time.
Madrid's pressure started to tell late in the match as Mayoral glanced a header past David Soria to give his side a platform to build on.
A needless shove from Gabriel Mercado on Theo Hernandez then allowed Ramos to tuck away his second penalty, this time sending the goalkeeper the wrong way, but it came too late in the match for Los Blancos to nab a leveller.
SEVILLA (5-3-2): David Soria; Layun, Pareja, Lenglet, Mercado, Escudero; Vazquez (Mesa 79'), Pizarro, N'Zonzi; Muriel (Ramirez 62'), Ben Yedder (Carrico 89')
REAL MADRID (4-3-3): Casilla; Nacho, Ramos, Vallejo, Theo; Kovacic, Ceballos (Mayoral 70'), Casemiro (Llorente 87'); Vazquez, Benzema, Asensio