"I have decided to leave the national team. I think my time there has finished," the 34-year-old Barcelona player told a news conference.
"It has been a wonderful, fantastic period for me. It has been an honour," said Xavi, who played a decisive role in Spain's triumphs at the World Cup in South Africa in 2010 and in Europe in 2008 and 2012.
"We have managed to achieve many successes in the past six or eight years and now I am just another fan of the Spain team," he said, explaining that he will stay with Barcelona.
Xavi revealed that he had planned to leave the national side after Spain's 2012 Euro win, but coach Vicente del Bosque persuaded him to stay.
"He insisted I stay for Brazil and Brazil was disappointing for everyone collectively and for me also individually," he said.
"The fact that I did not take part in the decisive game against Chile was a personal disappointment," said Xavi of the match that Spain lost 2-0, ensuring their exit from the World Cup in Brazil in the group stages.