A man in New Zealand got a huge surprise when he accidentally caught a great white shark while surfcasting.

Joel Gray and his friend were surf fishing off Matatā Beach when he hooked the sea creature. After struggling to reel the fish in for several minutes, he realized the catch was much larger than expected as it was a great white shark, reported Ladbible.

Gray said he and the onlookers were shocked when they finally saw the shark.

"Me and my mate were out the day before in kayaks in the same spot," he told Stuff. "Never seen one before around here, only baby hammerheads or bronze whalers. It was an exciting experience."

"The people were all pretty freaked out and amazed at the same time as they'd been swimming there not long ago. They were locals and said they have never seen a great white around before that day," he said further.

Gray also told the outlet the shark was about 9 feet long and appeared to be a juvenile. However, it was strong enough to break the fishing line and swim away.

The incident took place days after authorities issued a warning about an increase in shark sightings in the area.

"If you are visiting the ocean you need to be a little bit vigilant of what's happening around you and swim where there are surf lifesaving patrols and don't swim or dive alone," Clinton Duffy, a marine expert at New Zealand's Department of Conservation, said as per Stuff.

"If you are heading out on the water exercise caution and avoid swimming in the main channels where there are a lot of birds diving or belaying from kayaks and jet skis when fishing," Duffy added.

The great white sharks, which are the world's largest known predatory fish, can grow up to 21 feet in length and weigh between 1,500 and 4,000 pounds. They usually feed on fish, turtles, seals and small whales.

They are protected under the Wildlife Act 1953 in New Zealand, which means they can't be harmed or killed. It is not illegal to accidentally catch them, but they have to be released back into the waters without being hurt.

A shortfin mako shark being fished for sport in The United States in 2017
A shortfin mako shark being fished for sport in The United States in 2017 GETTY IMAGES NORTH AMERICA / Maddie Meyer