Two men are in hospital after terrifying home invasions during an armed rampage through Mandurah suburbs.

A group of three or four people forced their way into two houses, demanding money and drugs.

Several shots were fired also into a telephone box on Waterside Drive in Dudley Park.

Police say the group forced their way into a house on Steerforth Street in Coodanup.

They threatened the residents before assaulting a man in his 40s, who suffered critical injuries and was taken to Royal Perth Hospital.

Detectives believe the offenders, who were driving a sedan, fired a gun before they left.

The group then allegedly forced their way into a house on Killarny Street in Meadow Springs.

They again threatened those inside before assaulting a man in his 30s.

The man suffered serious injuries and was taken to Peel Health Campus.

Police allege the group fired shots before leaving.

Both men are in hospital and are expected to make full recoveries.

Mandurah Detectives and Regional Operations Group and forensic specialists are currently investigating the three linked incidents, which happened between 7.15pm and 10.30pm last night.

Detectives are asking locals to check their CCTV for any suspicious activity.

And anyone who was driving in the area between 7.45pm and 10.30pm is asked to come forward if they have dash-cam footage.

Anyone with information relating to this incident is urged to call Crime Stoppers on 1800 333 000 or report online at www.crimestopperswa.com.au