A whale has finally managed to free itself after spending hours stranded on a sandbar in waters off Stradbroke Island, east of Brisbane.

A Queensland Parks and Wildlife (QPW) spokesman said they first received reports on Thursday night of a mother and calf stranded on the sandbar at Dunwich, on North Stradbroke Island.

He said they managed to free themselves before the mother was re-stranded closer to shore this morning.

Footage shot earlier this morning showed the distressed calf swimming nearby and apparently trying to push it off.

At about 8:15am the mother managed to free itself.

A QPW boat is trailing the whales to help herd them out to sea and away from shallow waters.