Arsenal winger Robert Pires has agreed a two-year contract with Villarreal.
Pires joined Arsenal from Marseille for £6m in 2000
Pires will join on a free transfer subject to passing a medical - bringing to an end his six-year career as an Arsenal player.
"I have decided to accept a new challenge at Villarreal for the next two years of my career," said Pires on Arsenal's website.
Pires, 33, would have been out of contract with the Gunners in June but had been offered a new one-year deal.
He is not only a great footballer but a good man - we are sad to see him go
Arsenal manager Arsene Wenger
Pires added on the Villarreal website: "I am delighted to have signed for Villarreal for the next two seasons and hope to help the club to continue the great work they have done in the past few years."
The former France international was the Football Writers' Player of the Year in 2002 and won two Premiership titles and two FA Cup winners as an Arsenal player.
Pires made 284 appearances for the London club.
Arsenal manager Arsene Wenger said: "Robert has had six tremendous years with us and made a huge contribution to the team's success during his time here.
"He is not only a great footballer but a good man, so of course, we are sad to see him go.
"I would like to thank Robert for the dedication, determination and passion he has shown and wish him well in his career."
Arsenal signed Pires from Marseille for £6m in 2000. His final match for the Gunners was the Champions League final, when he was substituted in the first-half following the dismissal of goalkeeper Jens Lehmann.
He made 284 appearances for Arsenal in all competitions, scoring 84 goals.
Pires is expected to be officially unveiled as a Villarreal player on either 2 or 3 July.