A homeless man fashioned a machete-like blade to a groomed tree branch and speared a hungry black bear cub that was sniffing for food Friday morning at an illegal camp site in Anchorage.

The cub, estimated to be about a year and a half old, and an older bear thought to be its mother had been at the camp site for days stealing food, authorities said.

On Friday morning, the cub was seen outside a tent. David Tandler, 49, told officers he was worried it would harm children inside the tent, Alaska State Troopers spokeswoman Beth Ipsen said in an email to The Associated Press. No children were present at the camp site when troopers arrived.

Tandler picked up the spear, which he had earlier prepared for protection by attaching the long knife blade to the branch, said Dave Battle, the Anchorage-area biologist for the Alaska Department of Fish and Game.

Battle said Tandler threw the spear at the cub, hitting it in the side. The bar ran for about 20 yards before collapsing and dying.

"It's the first time I've run across the spearing of a bear," Battle said.

Authorities determined the bear kill was legal under the state's defense of life and property law.

Tandler was issued a $310 citation for negligent feeding of wildlife because food and garbage was present at the illegal camp site and that is what attracted the bears. The camp was already under orders to be dismantled when the incident happened. Those living in camps have several days to clear their belongings before officials step in and do it.

The sow had climbed a tree while authorities were investigating. It eventually came down, but circled the camp site and started to eat some food at the camp. Troopers fired a rubber bullet, scaring the sow off.

The people in the camp were evacuated for their own safety.

"The sow will continue to come in," Battle said. "For one thing, it lost a cub there, and it found a smorgasbord there."