A 16-year-old boy was mauled and killed by a black bear during a running race in Alaska at the weekend, managing to text his family as the attack was under way, authorities said Monday.

Patrick Cooper, of Anchorage, was competing in the annual mountain race on Sunday that goes through rugged terrain when he apparently encountered the bear.

He reportedly texted a member of his family to say he was being chased by the animal.

"The mother was here with her family, her children, they were running the race," Nathan Michell, of the Anchorage police department, told reporters.

The race director said the boy had raced up a mountain and was on his way down extremely steep terrain that goes through thick wilderness when the attack took place.

Several fellow runners and rescuers rushed to the site but initially couldn't get close as the animal was still in the area.

"The bear was remaining in the area where the young man was," Tom Crockett, a park ranger with Chugach State Park, told local media.

He said a park ranger shot the bear in the face but the animal managed to escape. Cooper's body was found about 500 yards from the trail in heavily wooded terrain.

Bear encounters are not common in the area and it was unclear what prompted the attack, Crockett said.