Tokyo, Japan has been selected by the IOC meeting in Buenos Aires, Argentina, to host the 2020 Olympic games.
The games will be returning to Tokyo for the first time since 1964.
Istanbul and Tokyo were through to the final vote to host the 2020 Olympics and Paralympics after Madrid was eliminated in the first round.
The Spanish capital and Istanbul were tied in the original electronic ballot, with Madrid then losing out on a second decisive vote by 49-45.
Tens of thousands of people were left dejected in Madrid’s Puerta de Alcala square after the news was announced it had failed in its attempt to win the summer Games for a third straight time.
The Spanish capital’s bid had emphasised providing a “sensible, reliable and trustworthy” Olympics.
Its presentation revealed 80% of potential venues were already built and in use, although the delegation was also keen to stress that “Madrid is fun” and a popular tourism destination.
“We were full of optimism and nobody was expecting this,” said Spanish waterpolo player Jennifer Pareja, who was part of the Madrid delegation.
All three cities had made their presentations and described why they should stage the Games earlier on Saturday.
The winning city was announced tonight by IOC president Jacques Rogge after a final vote.
Jacques Rogge will be retiring after 12 years in the role, on Tuesday.