A dreadful error from Qatar goalkeeper Qasem Burhan gifted Bahrain a 2-1 victory in their Asian Cup Group C dead rubber in Sydney on Monday.
Both sides were left to play for pride in their final pool match at Stadium Australia following defeats to Iran and United Arab Emirates.
Bahrain midfielder Sayed Dhiya opened the scoring in an entertaining encounter with a well-taken, close-range finish 10 minutes before half-time.
Qatar had failed to take advantage of a number of opportunities earlier in the match, but Hassan Khalid Al Haidos looked to have sealed the point their play merited with a 68th-minute free-kick.
However, there was to be a final twist in the tale as Burhan somehow allowed a cross-cum-shot from Sayed Ahmed to loop over his head and into the net eight minutes from time.
Striker Mohammed Muntari spurned two clear chances to give Qatar the lead in the early going.
First, Muntari fired narrowly wide from a long ball over the top of the Bahrain defence and he then headed against the corner of the crossbar from a left-wing free-kick.
Bahrain did offer an attacking threat, though, and were unfortunate not to take the lead when Dhiya struck the base of the post with a diving header.
Forward Al Haidos had an effort cleared off the line as Qatar continued to pour forward but were caught by a sucker punch from Dhiya.
Dhiya converted from close range from Faouzi Aaish's pull-back following fine work down the left.
Muntari displayed further profligacy in front of goal at the other end by heading off target from a left-wing cross before Boualem Khoukhi was thwarted by a save with his face from Bahrain keeper Hamad Al Doseri.
Al Doseri came to the rescue again shortly after the interval as his fine one-on-one save kept Ali Assadalla from restoring parity.
Muntari finally put the ball in net only to be correctly flagged for offside, yet Al Haidos deservedly levelled matters with a low set-piece into the bottom right corner from the edge of the area.
Qatar saw chances to complete the turnaround wasted by Muntari, and they were punished as Burhan's clanger ensured that they exit the Asian Cup without a point to their name.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.