Spanish prime minister Jose Luis Rodriguez Zapatero was gracious in defeat after Madrid failed to land the role of hosting the 2012 Olympics.
"The first thing to do in an Olympic event is to be sporting and congratulate the winner, the city of London," he said.
"I also want to say how pleased I am with the very good work done by the Madrid candidacy."
Madrid was the third of the five bidding cities to be knocked out.
The bid attracted the most votes in the second round but was overhauled by London and Paris in the next stage.
"We thought the third round would be key," said Arantxa Sanchez Vicario, former Olympic-medal-winning tennis player and member of the Spanish delegation.
"We knew we were almost there but it didn't happen. I hope there will be another opportunity because I think Madrid deserves it."
Hundreds of people had packed the Plaza Mayor in Madrid from early morning to follow the International Olympic Committee vote in Singapore live on a giant TV screen.
Real Madrid star Raul, who was in Singapore to support the Spanish capital's bid said: "We must be proud of all the people who promoted this candidacy.
"I think Madrid will go on fighting because it deserves to be an Olympic city."
Madrid mayor Alberto Ruiz-Gallardon told reporters in Singapore that the city would now consider whether to bid for the 2016 or 2020 Games.
He noted that as a European city would host the 2012 Games, tradition indicated the next Games would be held in another continent.
But IOC president Jacques Rogge was full of encouragement for a repeat bid by the Spanish capital.
"I think Madrid has everything to hold an excellent Games," said Rogge.
"The future will be in the hands of Spanish sport and the mayor.
They must decide for 2016 or 2020 but the IOC
would be delighted with a new Madrid candidacy."