Carlisle United 2 Salford City 3: Carlisle United are almost certain of a play-off place despite losing to promotion rivals Salford at Brunton Park.
A 2-1 defeat for Mansfield Town to Harrogate Town means only a goal difference swing of eight on the final day can cost Paul Simpson's side a top-seven finish.
Carlisle's lingering automatic promotion hopes were ended but they look odds-on to be involved in the play-offs unless they lose to Sutton United, Mansfield win at Colchester United and the goal difference column also changes dramatically.
A win in front of a 10,927 home crowd would have kept them in with a shout of the top three but Simpson's side lost a dramatic game to Neil Wood's Ammies.
Salford bossed the first half and two quickfire goals from Callum Hendry and Luke Bolton put them in charge.
Carlisle responded well in the closing stages as sub Joe Garner and Kristian Dennis, from the penalty spot, brought it back to 2-2.
But Bolton swept in a late winner for the visitors, whose own play-off hopes received a major boost in the process.
United lost three players in the closing stages - Jon Mellish sent off for an altercation with Elliot Watt after the penalty was awarded, and sub Jamie Devitt going off injured.
It will leave Simpson counting the cost of those incidents as Carlisle now aim to mathematically secure their play-off finish - and then try to keep their promotion hopes alive in the end-of-season shoot-out.
Simpson made one change to his starting line-up, recalling Omari Patrick to replace JK Gordon, who started a three-game ban.
Taylor Charters returned to the bench for the Cumbrians, while visitors Salford named an unchanged side that included former United midfielder Watt.
Carlisle lined up with a back four as Mellish again started in attacking midfield, with Patrick and Ryan Edmondson the wide attackers either side of Dennis.
United looked to press their opponents' passing game but Salford had the first near-miss on eight minutes when a corner was headed on by Matt Smith and Owen Moxon, facing his own goal, diverted it against the left-hand post as Carlisle escaped.
Edmondson chased back well for Carlisle to inspire a counter-attack before, minutes later, Mellish fired wide after good work by Patrick and Dennis.
But Salford's shape and interplay always seemed better than United's and, after Hendry failed with one attempt, he opened the scoring on 24 minutes.
It came after the Ammies cut Carlisle apart down the right, Louie Barry feeding Bolton's overlap before Hendry arrived in space to shoot across Tomas Holy and into the bottom corner.
Salford continued to threaten after the opener, Barry almost wriggling through for a second before Bolton did make it two.
This one was poor from start to finish by Carlisle as the visitors managed to open up huge space down the middle, Bolton making a heavy touch but still able to get the shot away - and Holy only managing to get a weak glove on it as the ball bobbled into the net.
United, by contrast, offered only limited threat, their system struggling to make any headway.
Late in the half they created a couple of half-chances, Dennis slicing a shot over the bar and Owen Moxon firing wide from 30 yards, but major improvement was needed if Carlisle were to find a way back.
The lively Barry caused more problems with a break down the left for Salford, United eventually thwarting him in front of the box, and after Edmondson picked up a needless yellow card for dissent, the Cumbrians reached half time with plenty to do.
Simpson brought on Alfie McCalmont for Edmondson at the break as Carlisle reverted to 3-5-2, and early in the half the sub's skill earned a free-kick which led to Moxon having a shot blocked.
Later, Mellish turned into the box against Liam Shephard, who appeared to grab the Blues man - but ref Seb Stockbridge infuriated the Blues by giving Salford a free-kick instead.
On the hour a Jack Armer cross went unattacked by team-mates as Mellish was then denied a penalty as he went down under Theo Vassell's attention.
At the other end, a Salford corner broke for Smith but he couldn't get the shot on target - while Carlisle then found Ben Barclay in space on the right of the box but he pulled his first-time finish wide.
Simpson then made a triple change for the last 25 minutes, as Jack Robinson, Garner and Jordan Gibson all came on.
Robinson almost opened something up immediately but Dennis was given offside as he glanced the sub's cross wide.
United were having more of the play but still struggling to create anything more clear-cut, a Callum Guy cross bouncing just over Robinson as the sub attacked from the left.
Another opportunity saw Guy's powerful shot blocked well by Stephen Mallan, before Carlisle thought they'd found a way back when Robinson's far-post cross was headed home by Garner.
An offside flag, though, chalked off the goal, as Simpson then introduced Devitt for the closing stages.
Carlisle then did, though, get themselves back into things when a Moxon free-kick found Garner, who headed powerfully home.
That set up a dramatic finish and, with five minutes left of the 90, United thought they'd earned a point when Garner was hauled down in the box.
Ref Stockbridge pointed to the spot as Mellish was then shown a straight red card for an incident with Watt.
When Dennis could eventually take the penalty, he calmly beat keeper Alex Cairns as Brunton Park erupted.
But Carlisle failed to lock the door at the other end as, three minutes later, Bolton cut in from the Salford right into space and curled an impressive shot beyond Holy.
United then suffered a double late injury blow as Devitt had to go off with a hamstring injury, leaving them to finish the game with nine men.
Carlisle couldn't force a late chance to equalise but remained fifth in the table - and thanks to Harrogate's win at Mansfield should now be able to look forward to the play-offs.
Elsewhere, Stevenage secured promotion by beating Grimsby Town but Northampton Town's defeat to Bradford City leaves the third automatic promotion spot still up for grabs, with the Cobblers, Bradford and Stockport County all still in with a shout.
United: Holy, Barclay, Whelan (Gibson 64), Huntington, Armer (Robinson 64), Mellish, Guy (Devitt 75), Moxon, Patrick (Garner 64), Edmondson (McCalmont 46), Dennis. Not used: Kelly, Charters.
Goals: Garner 76, Dennis 85pen.
Booked: Guy, Edmondson, Garner, Dennis. Sent off: Mellish.
Salford: Cairns, Touray, Shephard, Vassell, Mariappa, Watt, Bolton, Mallan (Leak 80), Barry (McAleny 64), Hendry (Lund 75), Smith. Not used: Bellagambi, Lowe, Galbraith, Morton.
Goals: Hendry 24, Bolton 28, 88.
Booked: Touray, McAleny, Watt.
Ref: Seb Stockbridge.
Crowd: 10,927 (469 Salford fans).
Comments: Our rules
We want our comments to be a lively and valuable part of our community - a place where readers can debate and engage with the most important local issues. The ability to comment on our stories is a privilege, not a right, however, and that privilege may be withdrawn if it is abused or misused.
Please report any comments that break our rules.
Read the rules here