"They put a lot of pressure on us at the back and we found it very hard to make clearances," Transhorras said. "We had our chances to draw the match, but their second goal really killed the game."
Elche midfielder Mario Pasalic headed wide from an excellent cross in the 64th.
Rayo was reduced to 10 men when Jose Baena was sent off in the 78th for two yellow cards within minutes of each other.
Mendes broke through Rayo's defense thanks to a skillful one-two with Faycal Fajr and scored with a low shot under Rodriguez in the 84th.
Elche rose to 17th place on 20 points while Rayo stayed in 15th on 23 points after 22 rounds. Real Madrid leads the standing on 54 with Barcelona one point behind in second while Atletico Madrid is third on 50.