They took the lead when Algeria’s Aissa Mandi directed Youssef Msakni’s left-wing cross into his own net.
And some dreadful defending by Faouzi Ghoulam led to him bringing down Wahbi Khazri for a penalty which Naim Sliti coolly slotted into the right corner.
Algeria pulled a goal back when Sofiane Hanni struck from the edge of the area.
Tunisia’s victory takes them to three points and second place in Group B and leaves Algeria with only one point.
Group leaders Senegal can qualify later on Thursday by beating Zimbabwe.
It means Algeria, who had been one of the pre-tournament favourites, will have to rely on other results going their way if they are to qualify from the group – and they have to face Senegal in their final match.
Tunisia went into the game off the back of a 2-0 defeat to Senegal and anything other than victory against Algeria would have left them in serious trouble.
Click The Link for more information on Tunisia Reaching The Africa Cup of Nations 2017 Quarter-Finals Beating Algeria 2-1