A surfer has been attacked by a shark at Pyramids Beach, near Mandurah, south of Perth.

Police said the incident happened at about 9:00am on Sunday.

The man, who is believed to be aged in his 20s, has been flown to hospital for treatment, but his injuries are not considered life-threatening.

He was conscious and able to speak with paramedics, and he gave the thumbs up to friends and family on the beach before he was taken away.

The injured man was transported in the back of a vehicle to a waiting helicopter. ( ABC News: Liam Phillips )

St John Ambulance issued a statement saying the man "suffered traumatic injuries to a foot and ankle".

Surf Life Saving WA operations supervisor Jake Webb said the man managed to get himself out of the water before lifesavers reached him.

"[He] had already dragged himself onto the rock, he had four puncture wounds … the patrol treated him on the scene and moved him to the first aid room," Mr Webb said.

Surf lifesavers urging people to get out of the water after the shark attack. ( ABC News: Alisha O'Flaherty )

Mr Webb said some people chose not to leave the water, despite the beach closure and the advice of lifesavers.

Police had at one stage believed the man was sitting on rocks with his legs dangling in the water when he was bitten, but now say he was on a bodyboard in the water at the time of the attack.

There have been two other non-fatal shark attacks at Pyramids Beach in recent years.

A teenage boy was bitten on the leg by a two-metre shark in November 2014, and a grey nurse shark bit an 18-year-old man on the foot in October 2015.