Ten-man Algeria edged out Palestine 1-0 at the Azal Arena on Thursday to make it back-to-back wins in the Islamic Solidarity Games football competition and qualify for the semi-finals from Group B.
After a first hour that featured no real chances in Baku, Algerian substitute Farid El-Melali broke the deadlock from the penalty spot.
The Desert Foxes were reduced to 10 men when Ahmed Gagaa was dismissed, but closed out their second straight win in the tournament.
Algeria lead Oman by two points at the top of the group ahead of the clash between the two on Monday, when Palestine will have to beat already-eliminated Turkey to have any chance of reaching the last four.
Solidarity was on show on the pitch and in the stands, with the Palestine players giving their opponents scarves before kick-off and the two sets of supporters mingling happily in the crowd.
Palestine started with more vigour and purpose than their opponents, in front of a vocal group of fans in the best-attended match of the four to have been played at the stadium so far.
Ayman Sandouqa's men were the more physical of the two, which was not surprising given the average age of their squad is a couple of years older than Algeria's, who are looking to give youngsters experience with the 2020 Tokyo Olympics in mind.
The first half-chance fell to 17-year-old Palestinian forward Oday Dabbagh, who scored a brace in the opening 2-2 draw with Oman on Monday, but his strike was blocked.
The Ukrainian referee's penchant for awarding free-kicks led to a stagnated encounter, with the two teams cancelling each other out until Algeria won a penalty just after the hour mark.
El-Malali, 19, stepped up to confidently dispatch the spot-kick to score after coming off the bench for the second time in the tournament, after his brilliant equaliser in the 2-1 victory over Turkey on Monday.
That was the cue for the game to open up and Palestine went close to a leveller, as Islam Batran shot straight at Algeria captain Chamseddine Rahmani when he should have done better.
Palestine were given further hope when midfielder Gagaa received a second yellow card for a rash tackle on Mohammed Darwish with 15 minutes remaining.
But Algeria held on in the face of some heavy late pressure, as Rahmani saved Mohammed Salah's free-kick and Palestine striker Mohammed Maraaba miskicked with the goal at his mercy.