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 ($46.72 million) deal after undergoing a medical at White Hart Lane on Wednesday but Chelsea made a late swoop for the Brazilian, who can play as an attacking midfielder or winger.
It has been reported that Chelsea owner Roman Abramovich made an approach to his counterpart at the Dagestan-based club Suleiman Kerimov when a deal with Spurs appeared close.
Willian joined Anzhi from Shakhtar Donetsk in January, but the club's owner Kerimov has tightened the purse-strings, putting the entire first-team available for sale, according to media reports, and having sacked coach Rene Meulensteen.
He scored 20 goals in 140 league appearances for the Ukraine club before moving to Russia, and has been capped twice by Brazil.
PACKED MIDFIELD
Should the transfer go through, Willian will join Germany forward Andre Schurrle and Dutch midfielder Marco van Ginkel as summer arrivals at Stamford Bridge, and will add another body to an already packed roster of attacking midfielders at the club including Juan Mata, Oscar, Eden Hazard, Victor Moses, Kevin De Bruyne and Schurrle.
Manager Jose Mourinho has hinted that some players would have to leave, either on loan or on a permanent basis.
Willian's decision to opt for Chelsea, who can offer Champions League football, could also be seen as a victory for Mourinho over his former protege and current Tottenham manager Andre Villas-Boas, with whom he worked at Porto, Chelsea and Inter Milan before the latter struck out on his own.
"That's the danger of medicals before contracts," Mourinho said on Friday.
"The best thing to do is do the medical in secret."
Media reports have also suggested Chelsea are interested in signing former Barcelona and Inter Milan striker Samuel Eto'o, now at Anzhi, which may signal an end to attempts to buy Wayne Rooney from Premier League champions Manchester United.
Chelsea have had two bids rejected for the unsettled forward and despite Mourinho suggesting they may make a third offer before the transfer window shuts on September 2, a reunion with Eto'o, who helped Inter to the Champions League in 2010 when the Portuguese was in charge, may put an end to that.
(Writing by Pritha Sarkar and Josh Reich; Editing by John O'Brien)
