Both sides had chances to take the lead in an even opening period, with Bilbao winger Inai Gomez denied by the woodwork just before the break.
Just after the hour Rayo doubled their advantage in controversial circumstances when they were awarded a penalty for a challenge made inches outside the area.
Piti made no mistake from the spot to leave the home side with an uphill task to gain a positive result.
Bilbao did reduce the deficit with five minutes left when Mikel San Jose scrambled home when Rayo failed to clear a set piece.
A grandstand finish was set up as Rayo were reduced to 10 men in stoppage time after Alejandro Galvez picked up his second booking.
Rayo held on through five minutes of injury time to gain their fourth win in a row and move up to fourth in La Liga.