The Mexican triumphed in a rain-delayed race that saw Ferrari's Charles Leclerc finish second.
The Dutchman won his fifth race in a row and 11th in the season.
The Red Bull driver has taken his Formula One world championship lead into triple figures.
The Dutchman finished 17.8 seconds ahead of his Mexican team mate Sergio Perez.
Lewis Hamilton finished second for Mercedes.
Seven times world champion Lewis Hamilton finished second.
The 24-year-old Dutch driver took his 26th career win 0.9 of a second ahead of Spaniard Sainz, who closed the gap and set up a thrilling final chase thanks to a safety car deployment.
Mexican Sergio Perez, winner of the previous race in Monaco, was second on the streets of Baku.
The Mexican's teammate Max Verstappen finished third to stretch his Formula One championship lead over Leclerc.
The win ahead of Mexican team mate Sergio Perez completed a hat-trick for Verstappen.