Togo took the lead through a Serge Gakpe goal that looked suspiciously offside, with Tunisia equalising through a soft penalty conceded by Dare Nibombe.
Both sides had clear spot-kicks waved away in the second half, and Togo’s claim would have seen Tunisia goalkeeper Moez Ben Cherifia dismissed as he clobbered last man Emmanuel Adebayor.
Referee Daniel Bennett referee then controversially awarded Tunisia a penalty, also conceded by Nibombe - who had earlier been booked for someone else’s foul but not carded for either spot-kick- although Khaled Mouelhi missed that one.
Nibombe will miss the quarter-finals unless Togo appeal, which in turn would see Serge Akakpo suspended, but the West Africans did not care as they rode a frantic five minutes of injury time to hang on for the draw.
It was an extraordinary match by any standard, although played on a poor pitch.
Needing victory due to inferior goal difference, Tunisia defended with a high line, which caused problems throughout, as Togo sat deep and looked for the break.
Togo missed early chances when Floyd Ayite was denied by Khalil Chemmam, while Emmanuel Adebayor twice put wide.
They went ahead on 13 minutes as Tunisia failed to deal with a straight pass from Adebayor, Gakpe exploiting the high line to finish low past Ben Cherifia, although he looked offside.
Tunisia regained their composure midway through the first half, dominating passing and drawing level from the spot just after the half-hour mark.
The penalty was soft at best, Nibombe adjudged to have manhandled Walid Hichri at a corner. The finish was contentious too, Mouelhi stopping his run-up before rolling the ball home.
From that point Tunisia looked more dangerous, the lively Saber Khelifa denied a penalty when the turf prematurely ended his mazy run and the ball bounced up on to Akakpo’s arm. It would have been harsher than the previous spot-kick, and the referee turned away.
The second half continued with Tunisia in charge, and Bennett failed to award a clearer penalty when Oussama Darragi was chopped down by a wild hack from Vincent Bossou. He was well placed but the man in black waved play on.
Then Togo were denied a penalty of their own which, while not as clear as the one Tunisia had just seen rejected, was as awardable as the spot-kick that had been given. This time Adebayor got the better of Hichri, who did lay hands on the Spurs man, who in turn went down very easily.
As the half progressed, Tunisia’s line moved higher, mindful of the need to score. Togo were finding space again and should have gone ahead when Komlan Amewou kicked air after a brilliant run and pass from Adebayor.
Adebayor hit the angle of post and bar with a flying header, and two minutes later he was brought down by Ben Cherifia after racing one-on-one with the Esperance keeper.
Everyone thought it was a penalty as Tunisia surrounded Bennett but, inexplicably, he pointed for a corner, even though Ben Cherifia was nowhere near the ball when he flew straight into Adebayor.
Just to rub it in, five minutes later Tunisia were awarded a second penalty.
It was not even ironic that this one should have been the least awardable of the half-dozen claims – indeed, it appeared to be a dive by Khelifa – and there was little surprise that Nibombe, giving away his second penalty of the match, was not booked for the foul. Had he been carded, he would have been sent off, having been earlier shown a yellow for a foul committed by Akakpo.
In the confusion, keeper Kodji Agassa was booked, but he was delighted seconds later when Mouelhi put the spot-kick against the post.
Tunisia threw men forward, the introduction of young substitute Fakhreddine Ben Youssef causing problems. He was denied by a fantastic one-on-one save from the inspired Agassa, who flew out to block another finish from the youngster after a goalmouth scramble followed the corner.
Somehow Togo held on, to move into the last eight with delirious celebrations as Tunisia consoled the weeping Mouelhi.
Bennett, meanwhile, is likely to be culled for the remainder of the tournament, with Egyptian referee Ghaed Greisha having been sent home for lesser failures; fortunately this South African ref will have a shorter distance home.