Alonso's Ferrari had occupied first place for the majority of the session.
Ahead of a crucial race for his title hopes following his Suzuka first-lap exit, the Formula 1 championship leader put himself in front early on and then kept improving his time, eventually reaching a 1m39.450s.
With the field then switching to longer runs for the final half hour, it looked unlikely that Alonso would be beaten.
But four minutes from the end, Hamilton produced a 1m39.280s a long way into a stint to depose the Ferrari.
His strong pace continued, and as the chequered flag flew, Hamilton threw in a 1m39.148s on his 23rd lap of the run to give McLaren Friday morning honours by 0.302 seconds.
Red Bull's Mark Webber also made a late improvement, but it was not sufficient to get him above third.
His team-mate Sebastian Vettel was fifth, behind the second Ferrari of Felipe Massa. The Red Bulls both appeared stymied by heavy traffic at the end of the session - nearly tripping over each other at one point.
Mercedes duo Michael Schumacher and Nico Rosberg were next up, despite Schumacher heading to the garage for a while as he was unhappy with the feeling of the car.
While Romain Grosjean took eighth, his Lotus team-mate Kimi Raikkonen was 11th in the revised version of the car, featuring a Coanda-style exhaust among other updates.
The final top 10 spots went to Paul di Resta's Force India and Jenson Button's McLaren.
Jules Bianchi was the best of the Friday drivers in 13th place in Nico Hulkenberg's Force India.
Williams's Valtteri Bottas was back in 18th after a long spell in the pits having various major components changed to allow back to back tests with updated parts.
Giedo van der Garde returned to the Caterham cockpit and was 22nd despite a violent trip over a kerb.
Most drivers completed the session without drama, although Timo Glock was limited to 13 laps as his Marussia required attention to its steering.