Leo Baptistao home into the lower left of the net after getting a pass from Nacho and finishing the move with a right foot in the 87th minute.
The striker then assisted Andrija Delibasic's goal in the 90th minute.
With 19 points Los Franjirojos are level with Real Betis in the chase for the final Europa League spot, and have compiled a record of six wins, six losses and one draws on the season.
Los Bermellones are in 15th place, just one point above the relegation zone with a record of three wins, seven losses and three draws after 13 games.
Rayo Vallecano controlled possession for 67.8% of the contest thanks to strong open field play.
The Rayistas got off eight shots, including four on goal, during the match, a direct result of their 75 duels and 26 headers won.
Delibasic made his mark on the match for Rayo Vallecano after coming on for Alejandro Domínguez in the 79th minute, as he scored one goal.
David Cobeño pitched in with five stops.The combination of Nacho to Piti was the most common during the match, as the two players connected 15 times.
Mallorca had 32.2% of the possession during the loss.
The Barralets had nine shots, including five on target.The four attempts by Michael Pereira were the most of any Mallorca player.