Baku has been a city of oil for far longer than most people assume. Travelers wrote about flames and black liquid seeping out of the ground here centuries before the first drilling boom, and the medieval walled core, Icherisheher, became the first place in Azerbaijan on the UNESCO World Heritage List in December 2000. Around it sits a capital that spent its oil money on a Caspian promenade, a Zaha Hadid landmark and three skyscrapers shaped like flames.
It is a city of sharp contrasts, and that is the reason to give it five days. You can drink tea in a stone alley that predates the Ottomans, then ride a Soviet-built metro past marble stations and end the evening under LED flames on a hillside. Two of the five days are spent outside the center, because the country's best-known strangeness is out there: 6,000 prehistoric carvings and bubbling mud volcanoes at Gobustan, and gas fires on the Absheron peninsula. Baku itself is compact enough that the other three days are walkable.
The plan runs by area: day one the Old City and Fountains Square, day two the Boulevard, the Highland Park view and the Flame Towers, day three mansions and the Heydar Aliyev Center, day four Gobustan, day five the fires of Absheron. Start on a Tuesday, because the Heydar Aliyev Center is closed on Mondays and several museums keep short or irregular days then. Sunday and Monday make good spare days for the extra trips at the end. Baku is also the natural first step into Azerbaijan as a whole.