The 26-year-old Argentina international arrived in Valencia on Thursday evening after the fee - reportedly in the region of 3.5million euros - and personal terms were agreed, Los Che announced on their website.
Gago initially made a strong impression after joining Madrid for more than 20m euros from Boca Juniors in January 2006, helping the club to La Liga titles in 2007 and 2008.
But he fell down the pecking order following the arrivals of Xabi Alonso, Sami Khedira and Nuri Sahin, and spent last season on loan at Roma.
Sergio Canales looks set to join Gago in transferring from the Spanish capital to Los Che, with his loan move expected to be made permanent in the coming days.
The 21-year-old spent last term on loan at the Mestalla, but his opportunities were limited by two serious knee injuries.