The O'Farrell Government has suffered a stunning defeat to Labor in the Miranda by-election.

Labor's Barry Collier will return to State Parliament on the back of a 27 per cent swing - the largest swing ever recorded at a New South Wales by-election.

Mr Collier was previously a popular local member for Miranda, representing the seat in state Parliament from 1999 until choosing to retire at Labor's defeat in 2011.

The victory is a reversal of fortune for Labor just six weeks after losing Sydney seats at the federal election.

The by-election was triggered by the resignation of Sports and Recreation Minister Graham Annesley, who has left politics to take the chief executive role at the Gold Coast Titans Rugby League Club.

Mr Collier says he agreed to run again because locals urged him to come back.

He says local issues were crucial to his victory.

"I'm really feeling quite humbled to be returned by the people ... [to] represent them again," he said.

"They've been taken for granted and ignored on the local issues. It was the local issues, the lack of representation, the lack of strong representation in parliament by Mr Annesley."

Miranda lies in the centre of Immigration Minister Scott Morrison's seat of Cook, and would have been easily retained by the Liberal Party based on federal election results.

The victory is also a boost for Labor Leader John Robertson, whose judgment as leader had been questioned in recent weeks after revealing he had been offered a bribe by murdered Sydney businessman Michael McGurk.

Voters turn up to vote in the Miranda by-election on Saturday morning. ( ABC News: Joanna Woodburn )

As well as annoyance at Mr Annersley's resignation, the O'Farrell Government had been under attack over funding for Sutherland Hospital and local development issues.

Labor was assisted on polling day by firemen in uniform calling on voters to put the Liberal Party last over cuts in funding to fire and emergency services.

It was a message that carried extra weight with Sydney ringed by fire in recent days.

The result was worse than the 25.7 per cent swing at the Penrith by-election in June 2010, a result that predicted Labor's demise at the 2011 state election.

The Penrith result was also used as a justification for Labor to dump Kevin Rudd as prime minister.

The Miranda results is at odds with state opinion polls that have shown the Coalition maintaining a massive lead over Labor and Mr O'Farrell, well ahead of Mr Robertson as preferred premier.

Labor's victory appears largely a result of local factors and the return of the popular Mr Collier as Labor candidate.