Oman are through to the football semi-finals at the fourth Islamic Solidarity Games after Monday's draw with Algeria, while Palestine's hopes ended after they blew a big lead to lose to Turkey.
Oman - sitting on four points in Group B after a draw against Palestine and a superb comeback victory over Turkey - still needed a point to guarantee their progress to the knockout stages, and they did enough at the Azal Arena against an Algeria side who were already through.
Algeria, who had recorded wins over Turkey and Palestine, only needed a draw to top Group B, and they chose to rest several first-choice players, including two-goal top scorer Farid El Melali who started on the bench.
Oman took the game to Algeria early on with captain Abdul Aziz Al-Gheilani shooting just wide after 13 minutes before left-back Hassan Al-Saadi had an effort turned away by Algerian stopper Abdelmoumene Sifour.
But the breakthrough that Oman deserved came five minutes before half-time when left-winger Salaah Al Yahyaei provided an inch-perfect delivery for Muhsen Al-Ghassani who tapped in from close range for his second goal of the Games.
Victory for Oman would've seen them top Group B, but just as Algeria looked like surrendering top spot, Chafik Ameur's side conjured up a wonderful equaliser with their first attempt on target right on half-time.
Tayeb Meziani, who came on as a substitute for the injured Dhia Eddine Goudjil, flashed in a brilliant effort from inside the penalty area which sailed past Omani keeper Bilal Al-Balushi into the top-right corner.
A barely deserved equaliser for Algeria made it 1-1 at the break.
The second period lacked quality with both sides seemingly content with the draw that would take them both through to the semi-finals.
Algeria, who brought on El Melali to try and spice up their attack, sprang to life after 78 minutes with central midfielder Laid Ouaji playing a delightful ball through for El Melali, who was brilliantly denied by Al-Balushi, but the game petered out into a drab 1-1 draw which sealed second place and qualification for Oman.
Elsewhere, Palestine knew they needed to beat already-eliminated Turkey at the Bayil Arena whatever the result between Algeria and Oman, and they put themselves firmly in the driving seat with three goals in the space of 10 first-half minutes.
After a lively opening, 17-year-old Palestine forward Oday Dabbagh made it 1-0 after latching onto a superb through ball from Mahmoud Abuwarda, adding to his brace from the opening 2-2 draw with Oman.
Mohammed Maraaba atoned for failing to convert a one-on-one with Turkey keeper Ozkan Tastemur as he swept in Palestine's second, before Islam Batran steered in a third from the edge of the area.
Turkey looked like they were heading for a third defeat in as many matches, but Melih Okutan handed them a lifeline with a goal on the stroke of half-time.
Heading into the second half Palestine looked happy to sit deep and defend their lead, but Turkey appeared determined to go out on a high note.
Okutan grabbed his second of the game just after the hour mark, before Adbullah Balikci forced a stunning save from Palestine goalkeeper Mohammed Saleh with a crashing drive from distance.
Suddenly it was all Turkey, and captain Taylan Antalyali brought them level on 70 minutes after skipping through the Palestinian backline and firing home.
The astonishing turnaround was completed in the 80th minute, as Hakki Can Aksu fired low into the bottom corner to break Palestinian hearts.
Algeria and Oman thus progress to the semi-finals, and will be joined by the top two in Group A after the final round of matches on Monday evening.
Hosts Azerbaijan go head-to-head with Morocco in a top-of-the-table clash - with both teams locked on four points - while Cameroon, on two points, face already-eliminated Saudi Arabia.