A man in his 30s is in a serious condition after a shark attack on the New South Wales mid-north coast.

The man received five deep lacerations to one of his lower legs when he was bitten by a shark at Nambucca Heads after 7am on Sunday, an ambulance spokesman said.

Police said the 36-year-old was surfing near Scotts Head Beach when he was bitten on the leg by a shark.

He managed to swim to a nearby break wall, where a passerby saw him and contacted emergency services.

He was treated at the scene before being flown to John Hunter Hospital in Newcastle, where he was in a serious but stable condition.

Beaches in the area were closed, including Shelley Beach and Main Beach.