Second-placed Barcelona return to La Liga action later on Saturday (1900 GMT) against Real Sociedad after their Champions League last 16, first-leg win at Manchester City on Tuesday.
Real Madrid have 63 points ahead of Barca who along with Atletico Madrid, who face Osasuna on Sunday, have 60.
Illarramendi, replacing suspended midfielder Luka Modric, broke the deadlock with a shot that clipped off Manu del Moral and wrong-footed goalkeeper Manu Herrera after 34 minutes.
Real were missing Cristiano Ronaldo as he served the final game of his three-match ban and without him they lacked spark in front of goal against an Elche side who defended solidly.
Karim Benzema forced Herrera into a save early on and the French striker, along with Angel Di Maria, looked the most dangerous for Real but they still needed a slice of fortune with Illarramendi's effort to give them the lead.
Bale was having a quiet game on the right wing, but the Welshman came to life with a powerful shot that went in off the crossbar midway through the second period.
With Elche's resistance broken, substitute Isco then slotted home to wrap up the points.
"(Bale) didn't have confidence before scoring a great goal and after that he was totally different," Real coach Carlo Ancelotti told a news conference.
"I am satisfied because we didn't concede. Our play could have been better but at this stage of the season we need to be solid and we were. In tight games Modric gives us more options but Illarramendi did very well."
(Reporting by Tim Hanlon; Editing by Mark Pangallo)