Mohammed Al-Musallami guaranteed Oman's place in the last 16 of the Asian Cup with a last-gasp goal sealing a 3-1 victory over Group F rivals Turkmenistan.
The two teams appeared set to be eliminated with the scores locked at 1-1 after 83 minutes at Mohammed Bin Zayed Stadium, but Muhsen Al Ghassani and Al-Musallami got the goals they needed to advance as one of the best third-placed teams.
Oman took the lead in the 20th minute through a sensational free-kick from Ahmed Al Mahaijri, but Altymyrat Annadurdyyev drew Turkmenistan level before half-time.
After the Gulf Cup champions missed out on a penalty for a handball by Mekan Saparov, Al Ghassani put them ahead in the 84th minute and Al-Musallami headed home nine minutes later to complete a huge victory.
There was nothing the Turkmenistan goalkeeper Mamed Orazmuhamedov could do to stop Oman moving ahead through Al Mahaijri's 25-yard free-kick that flew into the top-left corner.
Annaguliyev Guychmyrat fired a glorious chance over when he was somehow not deemed offside, while Serdar Geldiyev had the ball in the net only for play to be pulled back for a perceived foul by Mekan Saparov on keeper Faiyz Al Rusheidi.
Turkmenistan got an equaliser in the 41st minute as a deflected pass fell kindly for Annadurdyyev, who drilled beyond Al Rusheidi at his near post.
Oman were unfortunate not to be awarded a penalty when Saparov handled the ball in the area and Orazmuhamedov pawed the deflection off the line, while Khalid Al-Hajri had a goal-bound shot blocked from the resultant corner.
Pim Verbeek's team ramped up the pressure and got their rewards when Al Ghassani turned home from Al Mahaijri's cutback six minutes from time.
And there were scenes of jubilation when Al-Musallami headed Salaah Al-Yahyaei's corner into the bottom-right corner to send Oman through to the knockouts for the first time in their history.