With five laps to go, the Red Bull driver’s luck came to an end when his left rear tire had a flat tire and he hit the concrete wall.
Verstappen couldn’t hold back his frustration when he got out of his car and kicked the blown tire.
The race was then suspended to clear up debris on the track.
The suspension offered Hamilton the chance to potentially win the Grand Prix, or at least finish second, ahead of Verstappen in the drivers’ title race, but trying to overtake Perez on the restart the Brit ran off the track while stopped.
Perez sped off to secure his first win for Red Bull and only the second of his career.
Sebastian Vettel took second place and gave Aston Martin his first podium in Formula 1, while Pierre Gasly finished third in the Alpha Tauri.
“I’m so happy for today,” said Perez after his win. “Usually Baku is pretty crazy, but I have to apologize to Max.
“He deserved the win today and it would have been good for the team to get a one-two, but the win is a fantastic result.”
Hamiiton described his conclusion to the race as “quite a humbling experience”.
“We worked so hard to get back into the top 10 and I risked everything but ended up losing,” Hamilton told Sky Sports.
“I clicked a switch that turned off the brakes, so when I restarted I just kept going on turn one. I am very sorry for the boys and girls on the team. Little did I know I even touched the ‘magic’ switch. “
Verstappen leads the drivers’ standings with 105 points, Hamilton with 101 and Perez with 69.
“We were in full control – it’s very disappointing what happened,” Verstappen told Sky Sports as he contemplated his crash. “We lost a lot of points – we could have opened a gap and with it happening so close to the end it’s very frustrating.
“It is what it is – we are still leading the championship even though we hit the wall.”
After six races, the next Grand Prix will take place in France on June 20th.