The 45-year-old senior officer suffered internal abdominal injuries and a laceration to his liver and was rushed to St Vincent's Hospital where he had overnight surgery.
Police went to the pub to arrest 33-year-old Nick Newman, a suspected child sex offender.
A spokeswoman for NSW Ambulance confirmed paramedics were called to a premises on Anzac Parade at 3.10pm.
'I was vacuuming here at work and I heard gunshots from a couple of doors away.
The ABC understands the incident was not linked to Australia Day celebrations or protests and witnesses have been encouraged to contact police.
An ambulance helicopter team responded to the scene and helped to treat the injured officer, who Fairfax Media has chosen not to name, before he was driven to hospital with a police escort.
The Scot said he saw the police officer being brought outside and he "didn't look very comfortable at all".
Police Minister Troy Grant, who drove from his home in Dubbo in the state's central west to visit, said nothing unified police more than a "stricken" colleague.
Police run towards a vehicle park following the stabbing incident.
Jose Mourinho signs extension with Manchester United
If Mourinho does stay until 2020, it'll be the longest he's stayed at a club in one single stint. If you cannot afford, you have to say "no, sorry, can't do that".
Sales assistant Lara Alexander was working at the nearby Pharmacy 4 Less when she heard "four or five" gunshots.
"I reckon [there were] about four, five shots, easy, "bang, bang, bang, bang, bang".
The incident took place nearby the Maroubra Junction Hotel, with patrons and staff directed by police to evacuate the area.
Police Association New South Wales President Scott Weber says he feels for the officer and his family and his thoughts and prayers are with the officer and his family.
"We were just asked to get out of here and go".
Homicide Squad detectives have now taken over the investigation, as is police protocol.
Police are seen at the Junction Hotel in Maroubra, Sydney, January 26, 2018.
Noel Whelan has been staying at the Maroubra Junction Hotel for a few months and was shocked when he was ushered out and into the street this afternoon.
The investigation will be independently reviewed and a report prepared for the coroner.