With 85 minutes played in the semi-final second leg, the Tunisians were leading 3-2 in Rades but trailing on away goals after losing the first leg 1-0 in Luanda.
Esperance goalkeeper Rami Jeridi then launched a long clearance that Haythem Jouini headed on and Badri took advantage of a deflection to score the decisive goal from close range.
It was the first time in the two-leg, 180-minute tie that Esperance led on aggregate and they survived a frenetic finish for a famous 4-3 overall victory.
Mohamed Belaili, Mohamed Ali Yakoubi, Jouini and Badri scored for Esperance and Geraldo and Lompala Bokamba for Primeiro in a seesaw showdown at the Stade Olympique near Tunis.
Geraldo put Primeiro ahead on eight minutes before Belaili converted a penalty and Yakoubi scored with a diving header to give the two-time African champions a 2-1 half-time lead.
A Jeridi howler gifted Bokamba an equaliser midway through the second half before a Jouini tap-in on 73 minutes edged Esperance 3-2 ahead on the night.
Primeiro thought they had scored a third goal soon after when Beadrik Ungenda netted in a goalmouth scramble, but it was ruled out by the overworked Zambian referee.
It was a surprise scoreline with Esperance scoring four goals for the first time in 12 matches and Primeiro conceding more than one in the Champions League for the first time this year.
Esperance will be away in the first leg of the final next month to Entente Setif of Algeria or Al Ahly of Egypt, who meet in Setif later Tuesday.
Record eight-time champions Ahly lead 2-0 from the first leg in Cairo and are expected to set up a repeat of the 2012 title decider in which they beat decades-old rivals Esperance.
There was plenty of off-field drama, too, with the flares that were flung on the pitch after the second Primeiro goal making visibility difficult.
Primeiro goalkeeper Adao ‘Tony’ Cabaca was affected by the smoke and after several appeals for medical assistance, eventually received help.
A small group of supporters played a cat-and-mouse game with the police, hurling various objects, retreating, then coming back to taunt them again.