The 27-year-old former Chelsea and Arsenal midfielder has completed a permanent switch to the big-spending Russian outfit alongside Nikita Burmistrov who has joined from Amkar Perm.
Anzhi chief executive Ayvaz Kaziakhmedo told the club's official website: "The signings of these footballers totally correspond to the strategy of our club achieving top aims.
"We are confident that, together with Lassana and Nikita, the club will fight for the most prestigious titles."
The experienced midfielder joins a host of high-profile names, including Samuel Eto'o, Christopher Samba and Yuri Zhirkov, in the ranks of the ambitious Dagestan club.
Diarra spent three-and-a-half seasons at the Santiago Bernabeu after joining from Portsmouth in January 2009.
The France international had also been a summer transfer target for AC Milan, who opted to sign Nigel de Jong from Manchester City instead.