Hamilton, a record eight-times winner at the Hungaroring who has now had turn two of the circuit named after him, lapped with a best time of one minute 18.729 in the on Friday's second afternoon session.
A ninth win at the circuit for the Briton would equal his own Formula One record for wins at the same track, nine at Silverstone. He will also be chasing his 10th Hungarian pole in Saturday's qualifying.
Leclerc, top in first practice when he was nearly half a second quicker than anyone else with a time of 1:19.075 before something broke on his car, was second fastest and 0.148 slower. McLaren's reigning champion and last year's winner Lando Norris was third, 0.499 off the pace.
Red Bull's Max Verstappen was fourth fastest, after being second in the earlier session when Hamilton was third.
George Russell was the best of the Mercedes drivers, fifth in both sessions but nearly a second slower than Hamilton.
Australia's Oscar Piastri was among five drivers to miss the opening session of the Budapest weekend as F1 teams fulfil a requirement to run rookies at least twice in a practice session in both cars.
Piastri finished in eighth place in his McLaren, second time out. However, Russell's championship-leading teammate Kimi Antonelli was 13th after missing the first session while Danish reserve Frederik Vesti gained track time.
"I almost spun twice on braking," said Antonelli over the Mercedes team radio. "What is going on? I keep locking the rears."
Russell had echoed his teammate, complaining: "The car feels dreadful. It's so out of balance."
Hamilton had been unhappy with his car's handling in the first session, saying over the radio that it felt "pretty bad. Ride is very poor. The stiffness is too stiff."
That all changed later on, with the seven-times world champion going top 15 minutes before the chequered flag.
Antonelli leads Hamilton by 45 points in the championship after 10 rounds.
The first session was briefly halted after Lance Stroll spun off in the upgraded Aston Martin and the Canadian did not return for the second as the team worked on his car's rear left suspension.
Teammate Fernando Alonso was 13th and 19th, his later best time 2.990 slower than Hamilton's lap and the jury is still out on the major changes to the car.
Alpine's Franco Colapinto crashed without injury at the final corner halfway through the second session, bringing out red flags.
Despite Ferrari's strong start to the weekend, after winning two of the previous four races, Leclerc and Hamilton had both held up Mercedes as clear favourites even if the track looked better suited to Ferrari's car than recent ones.
"I still personally expect Mercedes to be the reference and they are going to be very difficult to beat on the qualifying lap," said Leclerc.