Four people have been charged over a “horrendous and shocking attack” on two police officers in Melbourne.

Police were called to Fitzroy Street, St Kilda, about 3am on Sunday after a “vulnerable” woman was assaulted before they were attacked, with the head of one officer repeatedly smashed into concrete.

They had been trying to arrest a man and used pepper spray, when others intervened.

Both officers were taken to hospital, one with facial injuries and the other requiring surgery on his arm. Both have since been released.

A 26-year-old St Kilda man, a 27-year-old Langwarrin man, a 25-year-old Langwarrin woman and a 38-year-old Frankston man were arrested on Sunday.

They have all been charged with two counts of assault police, affray, violent disorder, intentionally causing injury and other assault-related offences and were to appear at Melbourne magistrates court on Monday morning.

Victoria’s Police Association secretary, Wayne Gatt, said it was a “horrendous and shocking attack” and it was sheer luck the outcome had not been tragic.

“It is only sheer good fortune that people punched or assaulted in that manner are not killed,” he told 3AW radio on Monday.

The police investigation is ongoing and investigators are continuing to review CCTV footage.