The 21-year-old Brazilian left Rayo to join the Spanish champions last June, but made only five appearances - and just one start - for Diego Simeone's side in La Liga before being loaned to Real Betis in January.
Baptistao was linked with a move to West Ham and Genoa, but will remain in Madrid after agreeing to join the club where he made a name for himself before sealing a switch to Vicente Calderon.
Rayo revealed that their new signing, who turns 22 later this month, will be presented to the media on Wednesday.
Neither club stated whether Baptistao will be eligible to make his second debut for Rayo against his parent club in their opening game of the La Liga season next Monday.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.