The Imola feature race winner had been running in 13th place for Trident before setting a 1m33.516s to claim pole, just 0.07 seconds quicker than the ART Grand Prix driver.
It continues his consistent run in qualifying so far this season, having qualified second at both Bahrain and Imola.
Alexander Smolyar will line up third for MP Motorsport, having topped the times earlier in the session before he was surpassed by Martins and then Stanek.
Hitech’s Isack Hadjar was the first driver to set a representative flying lap, with a 1m34.181s to top the timesheet early on.
But he was soon pushed down the order by Caio Collet (MP Motorsport), who was quickest with a 1m34.026s, before Van Amersfoort Racing’s Franco Colapinto and Martins also slotted in ahead of him.
The top 14 was running within just one second of the leader after the first runs, during which Stanek and William Alatalo (Jenzer Motorsport) took trips over the gravel at Turns 7 and 11 respectively.
Running resumed with 20 minutes left on the clock, with Hadjar briefly reclaiming the top spot before Ollie Bearman went fastest.
The Prema driver’s time at the top was shortlived, with Smolyar next to claim provisional pole with a 1m33.613s.
Martins was next to take the lead, going just 0.05s quicker, while Arthur Leclerc (Prema) slotted into third, with Bearman in fourth.
The field emerged for their final runs with 10 minutes left on the clock, prompting heavy traffic at Banc Sabadell, with some drivers running three wide in a bid to be last across the line.
The final order had looked set as Martins, Smolyar and Hadjar before Stanek’s last-minute attempt put him top of the timesheet.
Trident’s Zane Maloney has lost his reverse grid sprint race pole after failing to stop at the weighbridge during qualifying and has been penalised with a pitlane start for both races in Barcelona.
Maloney's penalties hand Saturday’s reverse grid sprint race pole to David Vidales (Campos Racing), with Juan Manuel Correa moving up to second for ART as he returns from a stress fracture in his left foot which caused him to miss the last round at Imola.
2022 FIA F3 Spain: Qualifying result