(Updates with exit poll)
By Chris Borowski and Christian Lowe
WARSAW, Oct 13 - Polish Prime Minister Donald Tusk was spared a humiliating set-back on Sunday when an exit poll showed a referendum to remove his close ally, the mayor of Warsaw, had failed to attract enough votes to be valid.
A TNS Polska exit poll for Polish broadcasters showed that turnout in the recall referendum was 27.2 percent, below the minimum threshold of 29 percent.
If that result is confirmed by the official results, mayor Hanna Gronkiewicz-Waltz will stay in her job until she finishes her term next year.
The 60-year-old mayor is deputy head of Tusk's party, a former central bank governor and one of the few women to reach the top of Polish politics.
Opinion polls before Sunday's vote had been predicting the referendum would succeed, with voters seeing it as a change to give their verdict on Tusk's government, now about to enter its seventh year in office.
His party is trailing behind the conservative opposition in nationwide polls. Some people in Poland, eastern Europe's biggest economy, feel his government has lost its way.
But there was only a trickle of voters at some polling stations in the capital, and many other residents said they saw no point removing the mayor just a year before her term ends.
"It's just a political game. The election is next year so we could vote then. Now we have to incur needless costs," said Zygmunt Kowalski, a 60-year-old pensioner.
(Additional reporting by Aleksandra Arendt and Pawel Florkiewicz; Writing by Christian Lowe)