Australia's World Cup knockout opponent was only decided in the dying moments of the final Group G matches.