Ayoub El Kaabi struck twice as African Nations Championship hosts Morocco beat Libya 3-1 after extra time to book their place in Sunday's final.
El Kaabi, the tournament top scorer, netted in the 72nd minute when he met substitute Zakaria Hadraf's fine cross with a powerful downward header to beat Mohamed Nashnush, but a horror error from Anas Zniti in the 86th minute gifted Libya an equaliser through Abdulrahman Khalifa to take the tie to extra time.
El Kaabi, now the top scorer in any single CHAN competition, then bagged his eighth of the competition with a backpost tap-in in the 97th minute before Walid El Karti struck 118th-minute penalty as Morocco won the North African derby to advance.
Morocco had never before reached the semi final of the biennial CHAN but have booked their place in Sunday's showpiece in Casablanca, where they will meet either Nigeria or Sudan, with the duo set to square off in Marrakech in Wednesday's second semi.
While Morocco perhaps lacked the abundant creativity that they've demonstrated in their run to the final four, they were nonetheless the dominant side during the opening 45 minutes.
The hosts enjoyed 66 percent of the possession before the break, with Libya's Motasem Sabbou being forced into a superb hooked clearance off the line from a Walid El Karti attempt as early as the fourth minute.
20 minutes later, the impressive Salaheddine Saidi slammed a header against the crossbar from another dangerous Achraf Bencharki delivery, with El Kaabi weakly meeting the rebound but only succeeding in heading it into the arms of Nashnush.
The Libyan stopper was forced to palm away a Bencharki free kick in the 38th minute, while Badr Boulhroude ambitiously attempted to chip the keeper from distance following an unconvincing Sabbou clearance.
After the restart, Jemal Sellami replaced Bencharki for Hadraf, although it was Libya who enjoyed the first real chance of the half when Abdeljalil Jbira cleared Saleh Taher's header from the arms of Zniti.
That chance appeared to spur Morocco into life, and less than 10 minutes later, the hosts had the breakthrough.
Tearing towards goal down the left-hand channel, El Kaabi's initial touch appeared heavy, but Ahmed Al Maghasi's diving tackle only succeeded in diverting the ball into the path of Hadraf.
The substitute sent in a fine cross which El Kaabi met with a powerful downward header to beat Nashnush.
Zniti had earlier demonstrated his bravery, diving low to deny Moftah Taktak, before his moment of madness allowed Libya in for an equaliser.
The stopper, appearing to attempt to beat the onrushing Khalifa five minutes from time, only succeeded in tapping the ball to the waiting Taher. As Zniti gave chase, the striker centred to Khalifa, who made little mistake firing past the backtracking Jawad El Yamiq into an empty net.
Despite their setback, Morocco rallied in extra time, and their set-piece dominance - a key feature of their run to the final - was again evident when Hadraf's fine corner delivery was headed on by El Yamiq and, after a deflection off Khalifa appeared to confuse Nashnush, El Kaabi was on hand to tap home at the back post.
Two minutes from time, El Karti took the tie beyond Libya from the penalty spot after he'd been brought down clumsily by Ahmed El Trbi, even though the defender did appear to take the ball. The forward halted his run up, drawing ire from Nashnush, but the stopper's protests went unheeded as Morocco advance 3-1.