Diarra seals deal with West Ham
The 31-year-old made the switch to east London from Ligue 1 side Olympique Marseille, where he has struggled since arriving from Bordeaux last year.
"I am very happy to be here at West Ham - everything is signed now which is good and I am excited to be here at this club and be playing for them in the Premier League," he told the club's website.
"I know a lot about West Ham as a club and when I knew they were interested in signing me, I was very happy and knew it would a good choice for me.
"The club has just been promoted and I am looking forward to a good challenge with the team ahead."
The transfer fee was not disclosed.
Diarra joined Liverpool in 2002 but did not make a senior appearance, spending two seasons on loan in France before signing with Lens in 2005.
The 31-year-old has been capped 44 times by France and was part of their Euro 2012 squad.