Xavi has signed a new deal with Barcelona until 2016.
The 30-year-old is currently preparing for the World Cup for Spain, but was back in Barcelona on Wednesday to sign the agreement with Barca president Joan Laporta.
"FC Barcelona and Xavi Hernandez, who were due to finish their contractual relationship on June 30, 2014, will add two clauses onto the contract this Wednesday which could keep the player at the club until 2016, depending on the amount of games played," Barca said in a statement on their official website.
Barca revealed that the new deal would allow Xavi "to retire at FC Barcelona, providing he remains an important player to the team".
In order to trigger the new clause, Xavi must play at least 50% of Barca's matches in the last two seasons of his remaining deal.
By the end of the extra two years, Xavi, who joined Barca at the age of 11, will be 36 and will have spent his whole career at the Catalan club.
The midfielder's release clause of 80million euros will remain the same.