A lightning bolt scorched and knocked out four people near the Sydney Opera House on Monday as they sheltered under a tree during a violent electrical storm, rescue officials said.

The four were struck beneath the tree in the Botanic Gardens, ambulance workers said, just a stone's throw from the harbourside architectural masterpiece.

"They all had a brief loss of consciousness," said New South Wales ambulance service's Dominic Wong.

They also suffered burns and presented cardiac symptoms, he told reporters.

The victims -- two men and two women aged from their late teens to their 30s -- were treated at the scene by paramedics and taken to Sydney hospitals in a "serious and stable" condition, he said.