Morales sealed the victory with a rasping long-range shot four minutes from time after having provided crosses for Weligton and Julio Baptista to head goals earlier in the game.
After a run of four games without a win in La Liga, it was a lift for the Champions League debutants, who host Borussia Dortmund in a quarter-final first leg next Wednesday.
Malaga moved on to 47 points, the same as fourth-placed Real Sociedad, who visit Espanyol on Sunday. Rayo are ninth with 41 points.
The visitors took the lead when Weligton was left unmarked to head in a Morales free kick after 22 minutes but Rayo were soon level when goalkeeper Willy Caballero was harshly ruled to have tripped Tito in the area.
Rayo captain Piti stepped up and scored from the spot, his 12th strike of the campaign.
Malaga restored their advantage in the 55th when Baptista leapt to meet a Morales corner and powered a header inside the far post for his first goal of the season.
Substitute Roque Santa Cruz volleyed wide from another Morales free kick but the Chilean made sure of the points with a 25-metre drive near the end.
Later in the day, Rubén García's goal gave Levante the lead in the 40th minute for a 1-0 win over Sevilla at Ciutat de València.
- Sports & Recreation
- Julio Baptista
- Borussia Dortmund