The Mexican triumphed in a rain-delayed race that saw Ferrari's Charles Leclerc finish second.
The Dutchman finished 17.8 seconds ahead of his Mexican team mate Sergio Perez.
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.
A tyre blowout denied Max Verstappen victory and Lewis Hamilton failed to score.
The Mexican said he was adjusting to his surroundings after seven years with the Force India/Racing Point team that is now Aston Martin.
Perez, who vaulted to fourth in the overall standings after Sunday's race, is the first Mexican driver to win a race since Pedro Rodriguez took victory in the 1970 Belgian Grand Prix.
The 33-year-old German replaces Mexican Sergio Perez at the team formerly known as Racing Point.
The Mexican missed the previous two Grands Prix at Britain's Silverstone circuit after contracting coronavirus.
Germany's Nico Hulkenberg will replace Perez at Sunday's British Grand Prix.