The 34-year-old, who was capped 133 times during a 14-year international career, was part of Spain's golden generation that saw the nation collect three major trophies.
Xavi played a significant role as Spain won back-to-back European Championships in 2008 and 2012, while adding the World Cup in South Africa in 2010.
At the Euro finals of 2008 he was named the player of the tournament.
His final campaign for the national team ended in disappointment with Spain failing to progress beyond the group stage in Brazil last month as they suffered defeats by the Netherlands and Chile.
He made his international debut in 2000, the same year he helped Spain win an Olympic silver medal in Australia.
Xavi, who has confirmed he will see out the final two years of his Barcelona contract, said: "I’m grateful for all those years and it has been a fantastic time.
"I'm grateful to everybody at the Federation, it's been a marvellous time for me to be there for so many years and have so much success.
“I'm leaving very proud and I wish them all the best. From now on I'm another fan of the Spain team."
As for quitting Spain at this particular time, following a dismal World Cup finals in South America, he added: "I was disappointed on two levels at the end of last season as I did not feel useful to Barca or to the national team.
"Brazil was disappointing for everyone collectively and for me also individually and the fact that I did not take part in the decisive game against Chile was a personal disappointment."
Xavi quits the international scene as his country's second most-capped player behind Real Madrid goalkeeper Iker Casillas, who has represented Spain 156 times.