The Frenchman will continue his career with the ambitious Russian outfit after being told that his services were no longer needed in Spain, while Nikita Burmistov also arrives
The midfielder initially appeared to be heading to Russia on a season-long loan, but the cash-rich outfit have now confirmed that he has joined on a permanent switch, along with forward Nikita Burmistov from Amkar Perm.
"The signings of these footballers totally correspond to the strategy of our club achieving top aims," CEO Ayvaz Kaziakhmedov told the club's official website.
"We are confident that, together with Lassana and Nikita, the club will fight for the most prestigious titles."
Anzhi were keen to add some more experience to their squad in order to fight for honours, and coach Guus Hiddink sees the France international as the ideal addition to his midfield.
The 27-year-old joined Madrid from Portsmouth in January 2009, and quickly developed into an important first-team member at the Santiago Bernabeu.
However, he has since lost his spot in the starting XI and was deemed surplus to requirements by head coach Jose Mourinho.
Diarra had also attracted the interest of AC Milan, but the Serie A side eventually opted to sign Nigel de Jong instead.