The visitors seemed to have one foot in the next round when they raced into a four-goal lead in Seville, only for Betis to bounce back in a thrilling first leg.
Almeria were 17th in the table and without a win in seven La Liga matches prior to kickoff, but made a rapid start against the Segunda Division B outfit.
Another who had seen limited action this term for Francisco Rodriguez's side, Quique, added a third on 29 minutes as Almeria's second string put out a first-half statement.
Things got even better for the away side after the interval as Edgar Mendez increased their advantage further on 62 minutes, but the complexion of the game changed dramatically with Ruben Castro's introduction.
Real's 12-goal top scorer bagged within six minutes of his arrival off the bench, and Damien Perquis reduced the deficit to two goals with a powerful strike beyond debutant keeper Damien Perquis on 86 minutes.
Jorge Molina shocked Almeria and gave Betis even more hope with a stoppage-time effort which left Julio Velazquez's team trailing only 4-3 ahead of the reverse fixture in Andalusia on December 16.