Mikel Rico lashed home the second goal in the 66th minute, just moments after Alberto Bueno had levelled for a Rayo side who gave the hosts plenty to ponder.
Mikel San Jose had given Athletic the lead in the 32nd minute but there was an element of good fortune about both Bilbao goals.
They could claim they deserved their luck, having seen Carlos Gurpegi's fifth-minute header rattle the crossbar before a great effort from Iker Muniain was charged down by Alejandro Galvez.
Even so, as they struggled to break down Rayo to create clear chances they took the lead courtesy of some lucky bounces.
Markel Susaeta's corner caused confusion in Rayo's defence. The ball fell for Mikel San Jose who tried to backheel the ball in. His effort struck the goalkeeper but was falling for Gaizka Toquero, and between them the two Athletic players got it over the line.
Even with their noses in front, Athletic struggled to impose themselves and Rayo began the second half well, eventually getting their reward thanks to some poor defending just after the hour mark.
After Athletic gave the ball away cheaply, Adrian could not keep his header down from Alhassane Bangoura's cross but the looping ball fell to the far post where two Rayo players had been left all alone.
Jonathan Viera could not keep his effort down but it fell for Bueno to turn in an overhead kick.
However, parity lasted only four minutes before Athletic pounced.
Aritz Aduriz and Galvez clashed trying to meet a low ball from the left wing, but Aduriz was first back on to his feet to lay it off for Rico to fire through the melee and into the net.
Andoni Iraola and Iker Muniain both had chances for a third but Rayo kept battling to the finish.