A juvenile shark has been rescued and returned to the sea after it was found in ocean baths on Sydney's northern beaches.

The dusky whaler was discovered in a Palm Beach rock pool on Tuesday morning after it was possibly washed in with the tide overnight.

A handful of locals had already finished their morning swim by the time the shark - estimated to have been 80 centimetres long - was found.

The pool was closed while a team of marine biologists were called to retrieve it and carry it a few metres to the open water.