"I am delighted the two clubs have come to an agreement," United coach Alex Ferguson told the club's official website.
"Nemanja is a quick, aggressive centre half and at 24 will be a terrific addition to the squad."
The Serbian international, who joined Spartak from Red Star Belgrade in July 2004, was linked with several clubs including Italy's Fiorentina and European champions Liverpool.
Vidic, 24, expressed recently his desire to seal a move to the English Premiership in order to prove himself in one of the greatest leagues in the world.
Ferguson needed to reinforce his defensive options after United were eliminated from the group stages of the UEFA Champions League.
United are in second place of the Premiership with 37 points, nine points behind leaders Chelsea.