A backpacker narrowly escaped death after slipping into the rapids at a Yosemite National Park waterfall, park officials said.

The hiker managed to pull himself from the torrents onto a boulder, where he waited until a helicopter crew arrived to help. The amazing rescue was caught on video recently released by the California park.

A ranger was lowered on a line down toward the rushing water, and video shows the ranger and the unnamed backpacker being hoisted back up toward the hovering helicopter. The man, who was treated for hypothermia, would have tumbled over the waterfall and died if he hadn't found the boulder, park officials said.

The accident happened on May 28 in an area of the park called the Inner Gorge.