VIENNA — Alexander Van der Bellen, a 72-year-old economics professor and former Green Party leader, won Austria’s cliffhanger presidential election on Monday, defeating his far-right rival by the slimmest of margins and pledging to unite the divided country.

Austria had to wait almost 24 hours after polls closed on Sunday for the authorities to count almost 700,000 valid mail-in ballots. In the end, Mr. Van der Bellen won 50.3 percent of the vote, and his far-right rival, Norbert Hofer, 49.7 percent, a difference of just over 30,000 votes, the Interior Ministry said.

Mr. Hofer conceded defeat on his Facebook page, writing: “Of course I am sad today. I would so gladly have taken care of our wonderful country for you as president.” He added, “The effort for this campaign is not lost, but an investment in the future.”