Travis Head scored a 69-ball century to deliver an unlikely Australian victory.