By Shadia Nasralla

VIENNA (Reuters) - The head of Austria's opposition far right Freedom Party (FPO) has posted online a text by a writer whose poem was used by the Nazis, causing an outcry only weeks before his party's candidate fights a neck-and-neck presidential election.

FPO chief Heinz-Christian Strache posted the excerpt from Ottokar Kernstock's poem "Be blessed without end", which served as the Austrian anthem between 1929 and 1938, on his Facebook page on Wednesday, Austria's national holiday.

In 1923 Kernstock penned the poem "The Swastika" for an Austrian national-socialist group. He died in 1928.

Strache, who has since removed the excerpt, wrote on Facebook Kernstock's text was the anthem of a "democratic Austria which ... was unfortunately dismantled by the Austrofascists and which afterwards had to suffer disastrous and cruel times under the (National Socialists)".

The post prompted independent presidential candidate Alexander Van der Bellen to ask his FPO rival Norbert Hofer to distance himself from it. The FPO was not immediately available for comment.

"One can call Kernstock one of those who paved the way for National Socialism," Van der Bellen told the newspaper Kurier. "What's keeping Hofer from protesting against this?"

Van der Bellen, a former Greens leader, beat Hofer in a vote in May by 31,000 votes. However, the result was annulled due to irregularities in counting postal ballots.

A rerun is to be held on Dec. 4, in which Hofer could become Europe's first far-right head of state in decades.

A spokesman for Vienna police said the case was with the prosecutor's office to see whether a crime had been committed. It is illegal in Austria to spread National Socialist ideas.

While the presidential race looks too close to call, the FPO has for months been leading opinion polls for parliamentary elections due in 2018, ahead of the two centrist parties who rule Austria, which was annexed by Nazi Germany in 1938.

The Newspaper Der Standard on its front page said of Strache's posting, apparently referring to Austria's Nazi annexation "whoever wants to go along with this must understand that this is a road to perdition, which we've been on once before".

Strache's posting followed criticism of the FPO's General Secretary speaking at a conference on Saturday about "the ethno-cultural crowding out of European peoples".

Social Democrat Chancellor Christian Kern described the conference as a far-right networking event and thanked organizers of protests against it for their actions.

(Editing by Alison Williams)