In a reverse of Friday morning’s FP1 session, Marquez led Martin by 0.174 seconds after posting a 1m57.823s on his final flying lap.
KTM duo Jack Miller and Brad Binder trailed the Ducati pair, while Maverick Vinales was fifth on his factory Aprilia as team-mate Aleix Espargaro crashed three times.
Championship leader Francesco Bagnaia was eighth and secured a place directly into Q2 for Saturday’s qualifying.
The hour-long second practice session took place under grey skies at the Sepang International Circuit, but the rain stayed away.
Marc Marquez set the early pace on his factory Honda at 1m59.515s before younger brother Alex edged ahead with a 1m58.705s just over five minutes in.
This would stay as the reference lap for a while, before Martin posted a 1m58.523s with around 38 minutes to go.
With just under 15 minutes to run, Bagnaia took over from Martin with a 1m58.493s, only to be immediately deposed by Yamaha’s Fabio Quartararo.
Quartararo’s 1m58.399s didn’t keep him top for long, as KTM’s Binder edged ahead with a 1m58.310s before Martin fired in a 1m58.227s with just under 11 minutes to go to return to the top spot.
Photo by: Gold and Goose / Motorsport Images
Jorge Martin, Pramac Racing
Martin moved to cement his position with a 1m57.997s on his final flying lap, but would be denied by 0.174s by Alex Marquez.
Miller jumped ahead of Binder at the chequered flag with a 1m58.232s, with VR46 Ducati’s Luca Marini shadowing Vinales in sixth.
Quartararo ended up seventh at the chequered flag, but was left livid with his Yamaha team-mate Franco Morbidelli when the Italian got in the way of his final flying lap.
Bagnaia, Marco Bezzecchi (VR46 Ducati) and Pramac’s Johann Zarco completed the top 10 to secure the last direct Q2 spots.
Morbidelli was just 0.084s outside of the top 10 in 11th after a late moment on his Yamaha, while Enea Bastianini on the factory Ducati will join him in Q1.
Both factory Honda riders will also face Q1 on Saturday morning, with Marc Marquez 15th and Joan Mir 16th.
A crash for Raul Fernandez left the RNF Aprilia rider down in 18th, while Aleix Espargaro was 20th after tallying his fourth fall of the day.
Ducati wildcard Alvaro Bautista was 2.547s off the pace in 22nd.