The Spanish club have confirmed the sale of the 28-year-old to Valeri Karpin's side for a fee believed to be worth around €7 million
The Argentina international joined Valencia from Montpellier in 2010, and has since made more than 100 appearances for the Liga side in all competitions.
"The club would like to wish the midfielder the best of luck on his latest journey. We thank him for his commitment and effort," a statement read on the club's official website.
The 28-year-old becomes coach Valeri Karpin's first major signing of the summer as they look to mount a challenge in both the Russian Premier League and Europa League next season.
Los Che agonisingly missed out on a Champions League spot last season after a final-day defeat to Sevilla, while Spartak finished in fourth place in the Russian top flight last term.
Costa, who has twice represented Argentina at senior level, joins compatriots Juan Insaurralde and Nicolas Pareja at the capital club.