The transfer, however, is subject to a work permit hearing on Wednesday.
"Chelsea Football Club can confirm an agreement has been reached with both Willian and his club for the transfer of the Brazilian player," the London club said in a statement on its website (www.chelseafc.com).
The 25-year-old appeared to be heading for London rivals Tottenham Hotspur in a 30 million pounds deal after undergoing a medical at White Hart Lane on Thursday but Chelsea made a late swoop for the Brazilian, who can play as an attacking midfielder or winger.
Willian joined Anzhi from Shakhtar Donetsk in January, but the club's owner Suleiman Kerimov has tightened the purse-strings at the Dagestan club, putting the entire first-team available for sale, according to media reports.
Image: Willian
Photograph: Epsilon/Getty Images
Have Chelsea beaten Spurs in race to sign Brazil's Willian?
Has Madrid finally set the stage for Bale's arrival?
EPL: Liverpool benefit from rivals' cast-offs to win again
La Liga: Vela earns Sociedad a draw, Valencia lose
The English Premier League no longer attracts the best