The seven-time world champion, who joined the Italian team in January last year but endured a season without a Grand Prix podium appearance for the first time in his career, came out on top after a lively and entertaining battle with teammate Charles Leclerc.
The race was won by Italian Kimi Antonelli, the 19-year-old who took Hamilton's seat last year, with former teammate George Russell second on a podium that offered a snapshot of Mercedes's past, present and future.
Mercedes team boss Toto Wolff said the podium, with Hamilton's former race engineer and Antonelli's current engineer Peter Bonnington joining the trio to collect the winning constructors' trophy, was one of the best moments of his life, and he felt overwhelmed.
"I have to say a huge congrats to Kimi, I'm so happy for you buddy, and I’m so honoured to be able to share this moment with him," Hamilton told the crowd at the Shanghai International Circuit, where he won a Saturday sprint race last season.
"He took my seat in this great team, and so a big congratulations to Mercedes."
"I had so much fun, and we had a great start. I wasn't able to keep these guys behind, but to stay in the fight, it was one of the most enjoyable races I’ve had in a long time, if ever."
The one-two was Mercedes' second in two Grands Prix, with Russell leading Antonelli in Australia last weekend and still leading the championship by four points.
Hamilton, with his mother on hand to witness his achievement on the day celebrated as Mother's Day in Britain, led briefly at the start and said he had learnt some lessons from the opening race where he finished fourth.
"We learned a lot in the main race (in Melbourne), brought it into this race," Hamilton told Sky Sports television.
"Still some improvements to be made, but my race pace has been really good, particularly on the hard tyres in these first two races.
"To fight back and get to third was a hell of a push, but just a massive big thank you to Ferrari for my first podium for them. It's a huge moment for me."
Hamilton said his battle with Leclerc, their cars even touching briefly, was what racing was all about and team boss Fred Vasseur said he had not wanted to intervene.
"I think it's an important step... I'm sure it will help us to come back," he said of Hamilton's podium.
"Now the target is Mercedes... we have to be lucid. It's a good weekend overall, but we are still far away from the Mercs. We have still four or five tenths, and it's a lot."
