Leclerc, 21, looked set to record his first win in F1 on just his second start for Ferrari when he lost power with 12 laps remaining, allowing five-time world champion Hamilton and Mercedes teammate Valtteri Bottas to take a one-two.
Hamilton, who was 23 when he won his first world title in 2008, immediately consoled Leclerc following the race and was quick to praise the talents of the Monegasque, who became the second-youngest driver to take the pole when he finished ahead of senior Ferrari teammate Sebastian Vettel on Saturday.
"You drove amazingly all weekend," Hamilton, 34, said to Leclerc before the drivers took to the podium after the race. "You have got a long, long career ahead of you, dude. I know it sucks right now."
"This weekend Ferraris have been incredible," Hamilton said afterward. "I had to see Charles [after the race]. He did such a great job, he had done the job to win the race. He deserved to win. It's a great result for the team, considering how hard the race was. But this guy here [Leclerc], has lots more wins coming in the future.
"He was already so strong this weekend. He'll bounce back, he'll grow, this will be another layer to his young greatness already and I'm looking forward to more battles with him."
Leclerc, who also recorded the fastest lap of the day to earn a bonus point, benefited from a late safety car as he hung on to finish ahead of fourth-place Max Verstappen. He now has 26 championship points from his first two races with Ferrari -- four more than Vettel.
"It was extremely unfortunate for Charles, he drove such a great race," Hamilton said. "We've got work to do to keep these guys on our tails."