In the first round, Istanbul and Madrid tied with 26 votes each. Tokyo had 42 votes, six short of a winning a majority. Istanbul then beat Madrid 49-45 in a tiebreak to advance to the final, which Tokyo won easily.
In their final presentations, Madrid made its case as the least-expensive option and Istanbul spoke of the historic opportunity to bring the Olympics to a predominantly Muslim country for the first time.
Madrid, bidding for a third straight time, had seemed to have gained the most momentum in recent weeks despite Spain's economic crisis and 27 percent unemployment rate. The Madrid team claimed the games would pose no financial risk because most of the venues were already built.
The Turkish delegation pressed its case of taking the games to a city linking the continents of Europe and Asia.
With the civil war in Syria posing a major issue, Turkish Prime Minister Recep Tayyip Erdogan said taking the games to Turkey "will send a very meaningful and strong message, not only to the world, but to our broader region."
"At this critical moment, we would like to send a strong message of peace to the whole world from Istanbul," Erdogan said.
IOC member Prince Albert of Monaco asked what hosting the games in Turkey would mean to the wider region.
"We believe that hosting the Olympics in Istanbul will give this signal, this spirit of friendship and sharing and peace," Erdogan said. "And our country is a place where there is a lot of unity and diversity, and that is the idea that we can share on a broader scale with the Olympics Games being hosted in Turkey."
Madrid said 80 percent of its venues were ready and only $1.9 billion was needed for construction, a fraction of the other two bids.
"Madrid has perhaps the most reasonable and responsible financial foundation in recent Olympic history," Spanish Prime Minster Mariano Rajoy said. "We can host the Olympics in 2020 with no risk to the Olympic movement."
AP Sports Writers Stephen Wade and Tales Azzoni contributed to this report. Follow Stephen Wilson on Twitter: http://twitter.com/stevewilsonap
- Photo gallery: Remembering Katrina 10 years...
- ACT scores, 2015: A breakdown of each state,...
- The 25 most educated cities in America: Where...
- Poll: Utahns would take Donald Trump over...
- 'North Dakota' not among potential new...
- Video: Bush returns to New Orleans for 10th...
- Calm on Wall Street: A turbulent week ends on...
- As Common Core results trickle in, initial...
- Poll: Utahns would take Donald Trump... 77
- Trump starts new media feud with... 36
- What keeps teachers from staying in the... 34
- GOP presidential candidate Jeb Bush has... 28
- Planned Parenthood alleges 'smear' in... 21
- USC's Steve Sarkisian apologizes for... 17
- Fired reporter kills 2 former... 17
- Trump says he's proud he booted... 16