Get all the latest news on coronavirus and more delivered daily to your inbox. Sign up here.

An off-duty police officer in California is being hailed for his quick-thinking after a hiker ended up trapped in a whirlpool on Saturday.

The Madera County Sheriff's Office said on Facebook the incident happened around noon when the 24-year-old hiker from Fresno attempted to cross Angel Falls near the village of Bass Lake, located about 14 miles from the south entrance of Yosemite National Park.

"The flow overwhelmed and swept him into a whirlpool, which held him under," the sheriff's office said.

HURRICANE SEASON ON THE HORIZON PUTS ADDED STRESS ON FEMA AMID CORONAVIRUS PANDEMIC

The sheriff's office said the 24-year-old misjudged the swiftness of the water when he decided to walk across.

With snow runoff, the cold spring water is flowing at about 50 to 80 feet per second.

Off-duty California Highway Patrol Brent Donley rescues a 24-year-old man from Fresno who ended up trapped in a whirlpool on Saturday. (Christina Donley via Storyful)

"That’s about like 50-80 basketballs full of water every second," the sheriff's office said.

As the man was struggling to stay above the water, an off-duty California Highway Patrol (CHP) officer just so happened to also be hiking nearby along the Willow Creek trail above Bass Lake.

Off-duty CHP officer Brent Donley, who also just so happened to be trained in search and rescue and in possession of a rope, quickly responded to help.

UTAH TEENAGERS SWEPT AWAY WHILE TUBING AFTER INTENSE WINDS, FAMILIES HOLD OUT HOPE AS SEARCH ONGOING

Donley saved the drowning 24-year-old by throwing him a rope and pulling in to safety as onlookers watched. Donley was able to then pull the man to safety with the help of other good samaritans.

CLICK HERE FOR MORE WEATHER COVERAGE FROM FOX NEWS

The off-duty officer stayed with the Fresno man and provided first aid until search and rescue deputies and EMS arrived at the scene.

"We sincerely thank Officer Donley for his quick-thinking and preparedness," the sheriff's office said. "This search and rescue call could have ended very badly if not for his help."

CLICK HERE FOR THE FOX NEWS APP

The sheriff's office said the man who was rescued was lucky and "needs to buy a lottery ticket." Officials stressed that those planning to visit the mountains, especially in spring as snow melts away, should not attempt to cross swift water.