Palestine edged Malaysia in a 6-5 thriller at the Asian Football Confederation Beach Soccer Championships in Thailand to finish the first stage as Group A winners.
At the tournament in Pattaya, today's result ensured the Middle Eastern nation, who have never medalled at the tournament, finished the group stage unbeaten.
Their win follows earlier victories over both hosts Thailand and Afghanistan.
Today a hat-trick from Maisara Al Bawwab proved crucial as a loss could have put them at risk of going out.
Bawwab scored straight from the kick-off to give Palestine the lead but it was 1-1 by the second minute after Ridhwan Zainal knocked in a rebound for Malaysia.
Malaysia then took the lead through Zaharim Yusof before Mahmoud Al Neirab levelled the tie once again in the second period.
Malaysia regained the lead just a minute later thanks to Quahairie Asaari but the scores were once again level when Al Neirab scored a superb bicycle kick in the 19th minute.
The score became 4-3 to Malaysia when Zaharim found the net again, but another goal from Al Bawwab ensured it was 4-4 as the penultimate period ended.
Al Bawwab completed his hat-trick with another goal straight from the kick-off to make it 5-4 and it became 6-4 in the 33rd minute thanks to Islam Abuobayda.
Malaysia got one goal back thanks to an own goal from Yousef Shaladan, but an equaliser proved elusive and the match ended 6-5, meaning Palestine's place in the next round was confirmed.
Luckily for Malaysia, even though Thailand beat Afghanistan 2-0 in today's evening session, they still go through in second place at the hosts' expense thanks to their superior head-to-head record.
In the day's other games the 2017 runners-up the United Arab Emirates beat Lebanon 3-2 to seal their place as Group B winners, while China thrashed Kyrgyzstan 9-3 in the same group.
Having already lost their first two matches, however, the result for China was too little, too late to see them through.
Today's results mean that in the first two quarter-finals, the UAE will face Malaysia, while Palestine will play Lebanon.
The other two quarter-finals will be decided tomorrow when group stage action comes to an end.