Real had seen Paris St Germain fight back with two late goals to draw their Champions League match on Tuesday night, but were not expected to be given much concern at the Mendizorrotza Stadium.
Gareth Bale was drafted in for a first start since early October, with Alphonse Areola replacing goalkeeper Thibaut Courtois and Luka Modric also returning to the team. Belgian playmaker Eden Hazard missed out as he nursed an ankle problem.
Bale almost broke the deadlock in the 11th minute after Isco had clipped the ball across from the left.
The Wales forward – at the centre of another country-versus-club row during the international break – glanced a header goalwards which beat the static Alaves keeper, but bounced back off a post.
Carvajal then picked out Isco, but the midfielder sent a close-range effort over.
Bale – criticised for his recent "Wales. Golf. Madrid" flag celebration – was not able to get enough contact on an effort at the back post, with Fernando Pacheco making a comfortable save.
On the half-hour mark, Alaves went close when defender Ximo Navarro put the ball wide after it came back in from a corner.
Pacheco was called into action again late in the first half to push away a 20-yard drive from Casemiro.
The tempo remained low-key during the opening exchanges of the second half, played out in driving rain.
Real Madrid finally broke the deadlock after 52 minutes. Toni Kroos floated in a deep free-kick, and captain Ramos was left unmarked to glance a header into the bottom corner.
Alaves were sparked into life after going behind.
The home fans were twice calling for a penalty, first for a handball by Modric and then what looked a trip by Ramos.
Referee Guillermo Cuadra did point to the spot in the 65th minute after Ramos pushed Joselu in the face with his trailing arm, and was shown a yellow card.
Perez, the former Arsenal and West Ham forward, made no mistake from the penalty.
But Real were soon back in front after 69 minutes.
Modric floated the ball in from the right. Isco's header at the back post came back off the woodwork and Carvajal bundled the ball in from close range.
Alaves forced a string of corners during the closing moments, as Perez's point-blank effort was blocked and then a header from Manu Garcia was saved by Areola.
The visitors closed out eight minutes of added time – with substitute Federico Valverde dragging a golden late chance wide.