Madrid had taken an early lead at the Benito Villamarin on Sunday thanks to a fine drive scored by Ballon d'Or winner Luka Modric.
But Sergio Canales hit back with a goal that survived a lengthy VAR review to seemingly claim a point for Quique Setien's side.
Former Betis star Ceballos had other ideas, though, coming off the bench to net a 20-yard free-kick with two minutes to go to move Madrid up to fourth.
Madrid started well and they took the lead in the 13th minute, Modric blasting a drive into the top-left corner from just outside the penalty area.
Vinicius Junior fired straight at Pau Lopez at the end of a flowing move as Madrid kicked through the gears, Antonio Barragan making a wonderful challenge to halt another rapid break.
Canales recorded the first Betis shot on target two minutes into the second half but Keylor Navas, deputising for the injured Thibaut Courtois, got everything behind the shot.
Navas was beaten in the 67th minute, however, the impressive Giovani Lo Celso sending Canales clear of the Madrid defence to squeeze his shot through the goalkeeper and over the line.
The goal was subject to a lengthy VAR review, giving the home fans an agonising wait, but replays showed Dani Carvajal was playing Canales onside and the goal stood.
Solari ignored Isco as he used his last two subs to bring on Ceballos and Brahim Diaz for his LaLiga debut, with the decision justified in the 88th minute.
William Carvalho gave away a free-kick on the edge of the Betis box and Ceballos took responsibility, bending the ball round the wall to beat Lopez.
What does it mean? Injuries mount for struggling Solari
Madrid, who are now 10 points back from leaders Barcelona, will hope an injury that forced Karim Benzema off at half-time is not too serious. Solari is already without forwards Gareth Bale and Mariano Diaz, while Toni Kroos, Marco Asensio and Marcos Llorente were also absent.
Ceballos justifies Solari faith
Bringing on Ceballos instead of Isco appeared a curious move and a decision Solari seemed certain to have to defend in his post-match news conference. But the former Betis midfielder settled the contest with a beautifully hit free-kick, earning Madrid an important three points.
Lopez wrongfooted by late winner
Ceballos took his winning goal nicely but, when he sees replays of the strike, Betis goalkeeper Lopez will surely feel he should have done better. The placement of his wall appeared odd as Lopez seemed to leave himself unsighted, allowing Ceballos to place a fine finish into his goal.