Having been asked to bat first on a lively pitch, England crumbled to 114-9 before Leach and Mahmood shared a crucial last-wicket partnership of 90 in Grenada.
Mahmood was bowled in the final over of the day for 49, his highest score in professional cricket, but not before he and Leach had dragged England to 204.
That represents an admirable recovery from England, who were facing being dismissed below 100 when they fell from 23-0 to 90-8 earlier in the day.
Captain Joe Root was caught behind for a duck in the morning session while three wickets fell for no runs in an abject spell after lunch - England unable to deal with the movement found by West Indies' pace attack.
But as the ball softened and pitch flattened out, Leach, who finished 41 not out, stoutly stopped the procession of wickets before he and Mahmood added valuable runs, including one fine Mahmood six.
They ensured England's bid to earn a first series win in the Caribbean since 2004, which would also halt their eight-match winless run in Tests, was not all but over on the opening day.
Unlikely fightback rescues England
Not since 1885 have numbers 10 and 11 top scored in a men's Test. Their effort was remarkable.
When Mahmood and Leach came together six of the top seven had made single-figure scores while the highest partnership in the innings was the ninth-wicket stand of 24 between Leach and Chris Woakes, who made an important 25 before becoming the third batter to be clean bowled.
Batting became much easier as the seam movement of earlier lessened, but that should not take away from Leach and Mahmood's performance.
At first it was all about survival, Leach digging in as he had famously against Australia during Ben Stokes' Ashes miracle in 2019, but as the partnership grew so did the attacking intent.
Leach drove the seamers down the ground and Mahmood, playing just his second Test, flicked seamer Kyle Mayers, whose day began by dismissing Root and Zak Crawley, over the mid-wicket rope.
With four balls to go, Mahmood cracked Jermaine Blackwood down the ground to the boundary. That took him beyond his previous professional best score of 45.
A ball later, with a maiden top-level fifty a run away, Mahmood tried to work the off-spinner into the leg side for a single but played on to his stumps.
He had to drag himself from the field but he left with his team-mates on their feet, applauding from the balcony.
Top order collapses as ball seams
The two drawn Tests in this series have been played on flat batting tracks, England showing positive signs in two draws.
Despite the Leach-Mahmood stand, the fact England's batters failed at the first sign of seam movement is of significant concern.
In the first session Crawley hit a loose drive to extra cover for seven, Root nicked behind and Dan Lawrence was trapped in front by Jayden Seales - the first of three wickets for the impressive seamer.
Trundling seam-bowling all-rounder Mayers took two wickets for no runs in his first five-over spell, justifying his selection over spinner Veerasammy Permaul.
England played and missed throughout the first two hours and, in truth, could easily have been further in the mire.
After lunch the tourists slumped further when Ben Stokes miscued a pull back to bowler Alzarri Joseph for two, Jonny Bairstow nicked behind to wicketkeeper Joshua da Silva for a duck and opener Alex Lees, who had survived 96 balls for 31, fell in the same fashion to Kemar Roach.
All three wickets fell with the score on 53. When Foakes was bowled by Seales from a ball that nipped back, numbers two to seven in England's batting line-up had all been dismissed for single-figure scores for the first time since 1951.
This series is being billed as the start of England's "red-ball reset". The period before Leach and Mahmood's stand was all too familiar. They are fortunate it was not terminal for their hopes.
'We tried to take it in little bursts - reaction'
England's Saqib Mahmood, speaking to UBERTALKS Sport: "I looked at the scoreboard when I was on 12 and thought 'well, I've got my average here'. We just tried to take it in little bursts and there were times when we were thinking 20 and 30-run partnerships.
"Some of the balls that the batters got were almost unplayable. The ball that Ben Foakes got swung away and nipped back and as a bowler you're taking that every time and you're not keeping those out as a batter. It was a pretty calm dressing room throughout - both teams wanted to bowl first and that tells you quite a bit about the wicket."
BBC cricket correspondent Jonathan Agnew: "This has been a lesson for England about how soft the ball goes once it's old. They have to emulate the way the West Indies bowled with the new ball in the morning. This is the sort of pitch on which Stuart Broad and James Anderson would have been a handful, but it's up to their replacements to do it."