Authorities revealed late Saturday that deputies shot and killed a man who was believed to be the primary target of a manhunt that lasted two weeks in the desert in central California.

Benjamin Peter Ashley, 34, was fatally struck by two deputies after he brandished a handgun. The deputies attempted to prevent him from walking on a rural road toward the foothills, said Ray Pruitt, the spokesperson for Kern County Sheriff's Office, according to the Associated Press.

Dozens of officers have been on a manhunt for Ashley, leading them to a remote terrain about 30 miles east of Bakersfield. He was spotted by a convenience store owner after he bought $100 worth of junk food at his shop, News Talk 610 CKTB reported.

The crime spree started on July 28 when the man took three men hostage in a cabin located in Twin Oakes after they confronted him about squatting on their property. The suspect detained the men for more than an hour and threatened to kill them before they managed to escape.

Two days later, a man named David Markiewitz, 64, was found dead in another cabin in Jawbone Canyon, about 10 miles away from where the suspect detained the three men.

Authorities had warned residents to stay inside and keep their doors and windows shut during the manhunt. They also closed a stretch of the Pacific Crest Trail in the southern Sierra Nevada, according to ABC7.