Villa fails to recover in time for Euros
Villa, Spain's all-time leading scorer, broke his left leg while competing in the Club World Cup with Barca in December, and has not played a competitive match since then.
"I tried right to the end but I wasn't able to get to 100 percent for the Euros," Villa said on his official Twitter feed.
"Today I called the coach to tell him. It was the most honest thing to do. Thanks to all of you for your support."
The Spanish football federation (RFEF) broke the news with an earlier statement.
"After failing to achieve the desired progress in recent training sessions, Villa spoke with Del Bosque," the RFEF said.
"[He] told him although he would like to be with the team in Poland and Ukraine, his physical state 'isn't the best' for a competition like the Euros.
"The RFEF and Spain's coaching staff wish the player all the best in his recovery and hope he will return soon to the national team, and value the effort made by David to get back to full fitness."
Villa has scored 51 goals in 82 national team appearances for Spain helping them victory at Euro 2008 and in the World Cup finals in 2010.
His Spanish international team-mates were quick to send messages of support on their Twitter accounts.
Barcelona's Cesc Fabregas wrote: "Keep your spirits up, you are a star. You have been and will continue being the best goal-scorer in the national team."
Chelsea winger Juan Mata wrote: "You have proved again you are an example, we will miss you a lot. You will soon be back scoring goals."
Barca's doctors had already said he would not make the King's Cup final on Friday, when Pep Guardiola's side take on Athletic Bilbao.
Del Bosque named a provisional squad for Euro 2012 last week which included many fringe players, and added Chelsea duo Fernando Torres and Mata on Monday after they helped their side win the Champions League final.
Del Bosque delayed naming any Barca and Bilbao players until after the cup final. He set May 27 as his deadline for deciding his final 23-man squad, when attention will focus in particular on their forward line without Villa.
Torres, Valencia's Roberto Soldado, Sevilla's Alvaro Negredo and Atletico Madrid's Adrian Lopez are already in the squad, while Bilbao's Fernando Llorente and possibly Barca's Pedro are expected to be called up, with others making way.
Spain won all eight of their qualifiers for Euro 2012 and are in Group C for the finals along with Italy, against who they play their opening game on June 10, Republic of Ireland and Croatia.