After losing to India by 24 runs, Australia needed Bangladesh to defeat Afghanistan, but not by more than 45 balls to spare, to progress to the last four.
In a bizarre match full of brief rain delays and Gulbadin Naib comically faking an injury to waste time to aid Afghanistan, star spinner Khan was the hero in setting up a dramatic eight-run win thanks to the Duckworth-Lewis calculation.
It comes just two days after Afghanistan had a huge upset win over Australia to put them in the box seat to qualify for a World Cup semi-final for the first time.
Undefeated India will now face England in the second semi-final, after being knocked out by the defending champions at the same stage in 2022.
Afghanistan will take on perennial semi-finalists South Africa for a spot in the decider.