In a dramatic finale to the race at Istanbul Park, championship leader Mark Webber and Red Bull team-mate Sebastian Vettel collided 18 laps from the finish, while first and second to gift McLaren the one-two instead.
Hamilton's victory ended a run of nine races without appearing on the top step of the podium, the 25-year-old's last win coming in Singapore last September while he was still champion.
Even then, McLaren came perilously close to a similar nightmare with Hamilton and world champion team mate Jenson Button running side by side and banging wheels in a furious battle for the lead.
Button finished 2.6 seconds behind him in second place.
Australian Webber, who had been heading for his third win in a row after starting on pole position, finished third to extend his overall lead to five points over Button.
Webber leads the standings with 93, while the McLaren duo moved up the standings with Button in second with 88 and Hamilton third with 84.
The day's big loser was Vettel, the 22-year-old German who had started the afternoon level on points with Webber at the top of the standings but paid the price for trying to pass the Australian down the inside on lap 40.
The two cars collided, Vettel's right rear tyre deflated and he spun off into retirement while Webber went off track but managed to come back.
Vettel slumped to fifth overall, 15 points behind Webber.
The German twirled his finger around his head as he trudged away from the car as if to say 'crazy' while team boss Christian Horner watched from the pit lane wall and shook his head in disbelief.
Red Bull's designer and technical head Adrian Newey simply buried his head in his hands.
Until then, Red Bull had looked to be heading for their third one-two of the season and second in a row.
Webber, whose lead had rarely amounted to more than a fraction of a second, held off Hamilton for lap after lap until Vettel got ahead at the pitstops.
Michael Schumacher finished fourth for Mercedes, the seven times champion a hefty 31.1 behind Hamilton, with team-mate and fellow-German Nico Rosberg fifth.
Poland's Robert Kubica was sixth for Renault and Felipe Massa gave Ferrari some points at least on their 800th grand prix start with a disappointing seventh ahead of Spanish team mate and double world champion Fernando Alonso.
Vettel takes first pole of F1 season
Red Bull deny using ride height system
Hamilton makes peace with McLaren
Spotted: Lewis Hamilton in Bahrain
Vettel joins Red Bull for 2009