Brazilian Vinicius Junior's neat chipped finish gave Real a half-time lead and Ramos curled home an excellent free-kick early in the second period.
Zinedine Zidane's side are level on points with Barca and despite an inferior goal difference moved top courtesy of their head-to-head record, having won and drawn against their arch rivals earlier this season.
Real went ahead in the 19th minute when Gareth Bale, making his first start since February, let Luka Modric's pass run onto Vinicius, who lifted the ball over the goalkeeper from a tight angle.
Vinicius's shot soon after hit the crossbar before skipper Ramos curled home an inch-perfect free-kick for his eighth goal of the season in the 56th minute.
Real Sociedad's hopes for a Europa League place were dented as they slipped to a third straight league defeat, 1-0 at home to Celta Vigo, for whom Iago Aspas converted the game's only goal from the penalty spot.
In Serie A, Lazio's title hopes were dealt a major blow after they let slip a two-goal lead to lose 3-2 at Atalanta.
Lazio missed the chance to close to within a point of leaders Juventus, with both sides still having 11 games to play.
Lukaku's penalty cancelled out Francesco Caputo's early opener for Sassuolo before Cristiano Biraghi fired Inter ahead in first-half stoppage time.
Milan Skriniar was sent off in added time for his foul on Lukas Haraslin, the Inter defender's second yellow card offence.
Dzeko cancelled out Manolo Gabbiadini's early effort for the visitors and then fired an 85th-minute winner to keeper Roma in fifth place.