Madrid's stuttering start to their domestic title defence continued with a 1-0 reverse against Real Betis at Santiago Bernabeu on Wednesday, but Zinedine Zidane's side have so far performed better away from home this term and that again proved to be the case in the Basque Country.
Cristiano Ronaldo started his second game of the week – despite a looming Champions League clash with Borussia Dortmund – but Madrid's hero was Ceballos, who netted the opener and then provided a quick response to Manu Garcia's 40th-minute equaliser.
That was Alaves' first goal of the campaign and the second could well have arrived here as they twice hit the woodwork in the second half, contributing to a nervy finish for Zidane's men.
Ronaldo and his team-mates were similarly profligate at the other end – also twice striking the post – but their failings ultimately mattered little as Madrid moved back to within four points of rivals and league leaders Barcelona, who play at Girona later on Saturday.
With a raucous crowd feeding off Madrid's early nervousness, Alaves started on the front foot and Keylor Navas was required to parry clear after a corner was flicked towards his near post.
But Ceballos soon eased the pressure on the visitors with the opener, wriggling out of a challenge with Ibai Gomez in the area to slide a finish inside the left-hand post.
Madrid quickly rediscovered their swagger and Lucas Vazquez should have added a second as he turned Marco Asensio's pinpoint cross over the top from close range, before Ronaldo missed the target and Nacho drew a smart stop from Fernando Pacheco.
A Madrid side missing the injured Marcelo at left-back then conceded the equaliser from that flank as Munir El Haddadi's centre invited Alaves captain Manu Garcia to send a thunderous header into the top-right corner.
However, the hosts were level for only three minutes. Pacheco came to challenge Ronaldo for a deep cross and succeeded only in knocking the ball into Ceballos' path for a low, sweeping finish.
Ronaldo clipped the outside of the post with a snapshot shortly after half-time and Isco then opted against presenting the Portugal forward with a clear opening as he bore down on goal, instead going alone and shooting at the legs of Pacheco.
A determined Ronaldo hit the upright again with a wonderful curling strike, before a rare attack at the other end saw Alaves likewise hit the woodwork as Alfonso Pedraza's shot deflected beyond Navas and against the crossbar.
Sergio Ramos unbelievably blazed over a gaping goal when Pacheco spilled the ball at his feet and it looked as though he and Madrid might pay the price for that miss when Pedraza ran through moments later.
But the Alaves substitute's stab under Navas bounced away off the frame of the goal again and Madrid escaped with the points.