The Mercedes driver's 55th career win was hard-fought and tense, with Ferrari's Vettel seizing the lead from Hamilton at the start and in the hunt all the way as the tyre strategies played out.
Hamilton was delighted with his performance.
In a ding-dong contest, first Vettel forced Hamilton wide at Turn One after he emerged from his second stop next to the Mercedes.
Felipe Massa collided with both McLaren cars.
After a mid-race safety auto eroded Buemi's early lead, di Grassi charged onto the Swiss driver's tail in the closing laps, eventually finishing just 0.320sec adrift. Vettel took on the soft tyre, the quickest, but less durable of the three compounds available here this weekend.
"He came out of the pits and I was a bit surprised that it was so close", Vettel added.
"Lewis and myself both picked up some wheel-spin straight away", said Vettel. This put Valtteri Bottas into the lead, though he was yet to make a pit stop.
HTC, Lenovo to develop standalone VR headsets with Google
The technology uses several sensors included in the device to make the virtual experience match the real world, as much as it can. Among them, perhaps the most impactful to the gaming industry is the next step in what Google is calling Daydream VR .
But on lap 25 Vettel made his move.
The next F1 race is the Monaco Grand Prix on May 28.
The virtual safety auto was deployed when Alonso's team mate Stoffel Vandoorne broke his car's suspension in a collision with Massa on lap 34. As a result, Vettel came out of the pit lane side-by-side with Hamilton instead of eight seconds ahead. Bottas clipped the rear-right wheel of Raikkonen as he went down the outside of the Mercedes at the first corner and the Ferrari bounced into the Dutchman.
"Having a battle and a fight with another team, it's so much more enjoyable", said Hamilton, whose new team mate Valtteri Bottas won in Russian Federation last month but retired in Barcelona with an engine failure.
Four-time title victor Vettel admitted he and Hamilton were "not best friends" but that he had "nothing to moan about" in the manner of defeat.
In the 2017 Drivers' Championship, Vettel maintains the lead spot with 104 points.
The Australian said: "I'm happy to be back on the podium today, it's the first one of the season for me which is nice but actually the race was quite a lonely one". "I pulled the clutch back in and then I could gain on him".
Union: Up to 40K walking off the job at AT&T this weekend
Union members want wage increases, no increase in healthcare contributions, and tighter job security protection from outsourcing. More than a dozen employees began their protest at 3 p.m. outside the AT&T wireless store at 1501 Walnut St.in Center City.
Stewards investigated the incident but ruled that no driver was wholly to blame.
Hamilton was not about to give up, however, and after gaining once more on the Ferrari he seized his opportunity on the 44th lap.
Sebastian Vettel lost the battle, not the Formula One title.
Earlier in the race Raikkonen and Verstappen retired after a coming together on the first lap, and it was Force India filling the gap with fourth and fifth for Perez and Ocon respectively. Alonso was only 12th while British driver Jolyon Palmer finished 16th and last of all the classified runners following another disappointing day at the office.
"Seb was really fast", Hamilton said after the race. "That is as close as it could be". The success of those improvements coupled with the Silver Arrows' clever decision-making has left Hamilton optimistic for the gruelling battle ahead.
"It was just the rawest fight I can remember having for some time, which I loved.
I don't know how we managed to lose that", said Vettel.
Sweden Drops Rape Investigation Against Julian Assange
He has been there ever since, fearing that if he is arrested he might ultimately be extradited to the United States. Police kept up round-the-clock guard outside the embassy until a year ago , when the operation was scaled back.
"He drove a fantastic race but I can understand how he feels". Well done to him.