Kimi Raikkonen (Ferrari) finished second Sergio Perez (Force India) ended third.
Hamilton passed Vettel when the German locked up while attempting to overtake Bottas at the safety vehicle restart with four laps to go, consequently finishing fourth.
Mercedes' Lewis Hamilton celebrates with a trophy on the podium after winning the F1 Azerbaijan Grand Prix in Baku City Circuit, Baku, Azerbaijan on April 29, 2018. After banging wheels earlier in the race on lap 12, the pair finally pushed too far as Verstappen aggressively defended, moving right and then left, leaving Ricciardo with nowhere to go resulting in contact and the duo ending the race in the run-off area at Turn 1. That in turn left Sirotkin out of the race and Fernando Alonso limping back to the pits with two punctures. With Romain Grosjean also crashing a lap later, the safety vehicle turned out to be a lengthy affair over the next four laps. The victory takes him to the lead in the drivers' rankings.
Soon afterward, Bottas' right-rear tire picked up a puncture, ending his race and elevating Hamilton to first.
Vettel had been in complete control of the race, but that all changed with just 11 laps remaining following a jaw-dropping, but perhaps inevitable crash between the two Red Bull cars.
Hamilton criticised race director Charlie Whiting for not stopping the race, rather than sending out a flat-bed truck to recover Grosjean's vehicle.
With the safety vehicle deployed, Bottas came into the pits for a set of ultrasoft tires, as did the entire field, and emerged in the lead ahead of Vettel and Hamilton.
ECB Leaves QE, Forward Guidance Unchanged
Business confidence in the 19-country bloc has already taken a knock, most notably in export-focused Germany. However, frequent suggestions of underlying weak inflation have called that timeline into question.
Bottas, meanwhile, revealed there was little he could have done to prevent the incident happening - and that he may need more than a few drinks to help him get over it.
"I have really mixed emotions as there were a lot of faults in the race and I struggled with the vehicle", Hamilton added.
"I tried to keep close to Raikkonen to make sure Sebastian didn't get close enough, and in the end we did it".
After the restart, the German made a mistake and dropped to fifth place. "I was very fortunate today so it feels a bit odd to me to be here".
"Obviously I was inside and I think he probably didn't see me", he said.
Behind the top four it was Sainz in the Renault, a cracking drive from Leclerc in the Sauber, points for Alonso and McLaren with a seventh place finish, Stroll giving Williams their first points of the season in eighth, Vandoorne adding to McLaren's points tally in ninth and Hartley taking the last points position for Toro Rosso.