Norbert Michelisz snatched pole position for the main World Touring Car Cup race at the Hungaroring in a qualifying shootout session in which 0.123 seconds covered the top four cars.
Home favourite Michelisz squeezed into the final part of qualifying by improving on his final lap in Q2, and opted to run second in the shootout order.
The BRC Racing Hyundai driver set a fastest first sector of all in his i30 N and went on to record a 1m52.784s lap.
Michelisz was forced to wait with bated breath while the remaining Q3 contenders ran, but his time remained unbeaten as he secured a fourth pole since the start of the WTCR era in 2018.
Points leader Esteban Guerrieri was a mere 0.008 seconds slower than the Hungarian, having forfeited most of his time in the opening sector.
The Munnich Motorsport Honda Civic Type R driver still went one better than he had managed on Saturday, and will share the front row with Michelisz.
Q2 pacesetter Yann Ehrlacher was 0.040s shy of Michelisz's time and will start the final race from third in his Cyan Racing Lynk & Co 03, ahead of reigning champion Gabriele Tarquini (BRC Hyundai).
Saturday race winner Nestor Girolami should have scored his second pole position of the weekend, but had his 1m52.546s shootout lap scrubbed off for a track limits offence at the fast Turn 4 left-hander and will start fifth.
Michelisz's late improvement in Q2 pushed Mikel Azcona - a podium finisher on his first WTCR weekend in Marrakech - out of the shootout.
The PWR Racing Cupra driver will start Sunday's final race from sixth, ahead of Thed Bjork (Cyan Lynk & Co), Augusto Farfus - who only attempted one Q2 run in his BRC Hyundai - and the second PWR Cupra of Daniel Haglof.
Jean-Karl Vernay threatened to improve on his final Q2 lap with a fastest first sector of all but did not improve in sector two or three and instead remained 10th - meaning the WRT Audi RS3 LMS driver will start the reversed-grid second race from pole.
British pair Rob Huff (Sebastien Loeb Racing Volkswagen Golf GTI) and Andy Priaulx (Cyan Lynk & Co) will start both races 11th and 12th respectively.
Saturday runner-up Yvan Muller was the biggest name to fall in the first part of qualifying, missing the Q2 cut by two tenths.
Having reported a "big vibration" at the front of his Lynk & Co on his outlap at the start of Q1, Muller never really threatened to secure a place in Q2 and could only improve to 14th on his final lap, before being shuffled back.
He will start 15th, two places behind the fourth BRC Hyundai of Nicky Catsburg - who missed out on a spot in Q2 by 0.044s.
Other drivers to fall at the first hurdle included KCMG Honda pair Attila Tassi (17th) and Tiago Monteiro (21st), Huff's three SLR team-mates Mehdi Bennani, Benjamin Leuchter and Johan Kristoffersson, and Gordon Shedden - who was 25th in his WRT Audi.
Race two starting grid
|2||Daniel Haglof||PWR Racing||Cupra|
|3||Augusto Farfus||BRC Racing Team||Hyundai|
|4||Thed Bjork||Cyan Racing||Lynk & Co|
|5||Mikel Azcona||PWR Racing||Cupra|
|6||Nestor Girolami||Munnich Motorsport||Honda|
|7||Gabriele Tarquini||BRC Squadra Corse||Hyundai|
|8||Yann Ehrlacher||Cyan Performance||Lynk & Co|
|9||Esteban Guerrieri||Munnich Motorsport||Honda|
|10||Norbert Michelisz||BRC Squadra Corse||Hyundai|
|11||Rob Huff||SLR VW Motorsport||Volkswagen|
|12||Andy Priaulx||Cyan Performance||Lynk & Co|
|13||Nicky Catsburg||BRC Racing Team||Hyundai|
|14||Aurelien Panis||Comtoyou Cupra||Cupra|
|15||Yvan Muller||Cyan Racing||Lynk & Co|
|16||Tom Coronel||Comtoyou Cupra||Cupra|
|18||Mehdi Bennani||SLR VW Motorsport||Volkswagen|
|19||Frederic Vervisch||Comtoyou Audi||Audi|
|20||Benjamin Leuchter||SLR Volkswagen||Volkswagen|
|22||Johan Kristoffersson||SLR Volkswagen||Volkswagen|
|23||Niels Langeveld||Comtoyou Audi||Audi|
|24||Kevin Ceccon||Team Mulsanne||Alfa Romeo|
|26||Ma Qinghua||Team Mulsanne||Alfa Romeo|
|27||Tamas Tenke||Zengo Motorsport||Cupra|
Race three starting grid
|1||Norbert Michelisz||BRC Squadra Corse||Hyundai||1m52.784s||-|
|2||Esteban Guerrieri||Munnich Motorsport||Honda||1m52.792s||0.008s|
|3||Yann Ehrlacher||Cyan Performance||Lynk & Co||1m52.824s||0.040s|
|4||Gabriele Tarquini||BRC Squadra Corse||Hyundai||1m52.907s||0.123s|
|5||Nestor Girolami||Munnich Motorsport||Honda||-||-|
|6||Mikel Azcona||PWR Racing||Cupra||1m52.733s||-|
|7||Thed Bjork||Cyan Racing||Lynk & Co||1m52.742s||-|
|8||Augusto Farfus||BRC Racing Team||Hyundai||1m52.743s||-|
|9||Daniel Haglof||PWR Racing||Cupra||1m52.772s||-|
|11||Rob Huff||SLR VW Motorsport||Volkswagen||1m52.885s||-|
|12||Andy Priaulx||Cyan Performance||Lynk & Co||1m52.948s||-|
|13||Nicky Catsburg||BRC Racing Team||Hyundai||1m53.118s||-|
|14||Aurelien Panis||Comtoyou Cupra||Cupra||1m53.168s||-|
|15||Yvan Muller||Cyan Racing||Lynk & Co||1m53.271s||-|
|16||Tom Coronel||Comtoyou Cupra||Cupra||1m53.293s||-|
|18||Mehdi Bennani||SLR VW Motorsport||Volkswagen||1m53.408s||-|
|19||Frederic Vervisch||Comtoyou Audi||Audi||1m53.426s||-|
|20||Benjamin Leuchter||SLR Volkswagen||Volkswagen||1m53.563s||-|
|22||Johan Kristoffersson||SLR Volkswagen||Volkswagen||1m53.629s||-|
|23||Niels Langeveld||Comtoyou Audi||Audi||1m53.695s||-|
|24||Kevin Ceccon||Team Mulsanne||Alfa Romeo||1m53.954s||-|
|26||Ma Qinghua||Team Mulsanne||Alfa Romeo||1m54.292s||-|
|27||Tamas Tenke||Zengo Motorsport||Cupra||1m55.276s||-|
Autosport has produced a standalone special magazine to celebrate our 70th birthday. All current print subscribers will receive a copy for free. To order your copy of the 196-page Autosport 70th Anniversary issue, please go to: autosport.com/autosport70th