Paul Broderick and Ciaran Moran scored second half goals as Carlow came from behind to register their third win in this year's championship at Leitrim's expense in Netwatch Cullen Park.
Twice trailing by four points early on and by two points (0-7 to 0-9) at the interval, the Barrowsiders came good after the restart to avenge last March's Allianz League defeat to the same opponents. More importantly, the victory guarantees Turlough O'Brien's men a place in Monday morning's All-Ireland SFC qualifier Round 3B draw and a fifth championship outing in 2017, which few would have predicted at the start of the year.
Both teams finished with 14 men after Chris Crowley and Brendan Gallagher were shown straight red cards in the closing stages.
Broderick, who top-scored with 1-6, opened the scoring, but Leitrim - who were attempting to bounce back from a heavy Connacht SFC semi-final loss to Roscommon - scored five unanswered points per late call-up Conor Cullen, Ryan O'Rourke and Brendan Gallagher to lead by 0-5 to 0-1 by the 13th minute.
A Gary Kelly free ended the Leitrim scoring sequence before a Ronan Kennedy free at the other end restored the visitors' five-point advantage.
A brace of Broderick frees reduced the deficit, but he was also guilty of some poor misses as scores from Gallagher and Kennedy ensured Brendan Guckin's charges of a two-point lead at the short whistle.
Points from captain Darragh Foley and Broderick (free) had the sides level on 0-9 each within seven minutes of the restart before the latter rattled the net in the 43rd minute after Sean Murphy had thundered through the middle. Sean Gannon and Foley added further points in a great spell for the hosts before O'Rourke finally opened Leitrim's second half account in the 56th minute.
Substitute Darragh Rooney tagged on another point, but the momentum remained with Carlow who had further points through Kieran Nolan, Ciaran Moran and Shane Clarke before Moran's major with seven minutes to go settled it.
Carlow - R Molloy; C Crowley, S Redmond, BJ Molloy; D Moran, D St Ledger, G Kelly (0-1); S Murphy, S Gannon (0-1); A Kelly, D Foley (0-2, 1f), E Ruth (0-1); P Broderick (1-6, 0-3f), C Moran (1-1), J Murphy. Subs: S Clarke (0-1) for A Kelly, M Rennick for BJ Molloy, K Nolan (0-1) for G Kelly, D O'Brien for P Broderick, J Clarke for D Moran, C Lawlor for S Murphy.
Leitrim - B Flynn; O Madden, P Maguire, M McWeeney; J Rooney, G Reynolds, R Gallagher; S Moran, D McGovern; B Gallagher (0-2, 1f), C Gaffney, C Cullen (0-1); R O'Rourke (0-4), R Kennedy (0-4f), G Plunkett. Subs: N McGovern for D McGovern (BC), D Rooney (0-1) for G Plunkett, D Moran for S Moran, N Plunkett for R Gallagher, K Keegan for J Rooney, K Beirne (0-1f) for R Kennedy.
Referee - P Hughes.