Austria has elected a 72-year-old former leader of the Greens party to be its next president, narrowly avoiding