The 32-year-old, a Euro 2008 and 2010 World Cup winner with La Roja, is his country's all-time leading scorer with 56 goals but will call it a day after their Brazil adventure.
"I don't like to say farewell, but obviously this World Cup will be my last games for Spain," he said on Spanish television channel Cuatro.
"Given my age, my level of performance, and everything I have given the team, it is time.
"Now I want to enjoy it from the first day, have a great World Cup and why not try to get another title?"
Villa was announced as newly-formed Major League Soccer club New York City FC's first signing on Monday, joining on a three-year deal from Atletico Madrid.
And, although he is stepping away from the international scene, he feels he still has plenty left to offer.
"It's one of the reasons I accepted this offer - because I still have a lot of football left in me," he added. "Otherwise, I would have gone home. I want to make a name for myself in this part of the world."