A Presque Isle man wanted in connection with a sexual assault investigation was shot and killed by pursuing officers after a 40-mile chase Thursday night through two states.

Michael Brown, 40, died of a gunshot wound to the neck after an hourlong chase in Massachusetts and New Hampshire, officials said. Police say Brown shot at Massachusetts State Police cruisers during the pursuit.

Brown was killed during a brief confrontation with several Massachusetts state troopers after the stolen pickup truck he was driving crashed in New Hampshire, said Jeffery Strelzin, senior assistant attorney general in New Hampshire. Brown was pronounced dead at the scene. After an autopsy Friday, his death was ruled a homicide.

Strelzin said during a news conference that a gun was found in Brown’s car. That gun and weapons fired by officers are being analyzed as part of the investigation, he said.

Presque Isle police told WCSH-TV that the truck involved in the chase was the same stolen pickup that had been linked to Brown. Presque Isle police sought the public’s help Thursday in locating Brown, who they say was wanted in connection with a sexual assault. Police said he was driving a gold-colored Toyota Tacoma stolen from an uncle and was believed to be armed with a 9 mm handgun. He was considered by police to be dangerous after he told a friend he had no plans to be arrested.

Police in Malden, Massachusetts, initiated the pursuit around 11:10 p.m. when they recognized Brown as the man wanted in Maine in connection with sexual assault, firearms and stolen motor vehicle charges. The chase went through the Merrimack Valley and ended at the intersection of Bear Hill and Amesbury roads in Newton, New Hampshire, Strelzin said.

Massachusetts State Police took over the chase after Brown left Malden. The pursuit ended after Brown drove over spike strips and crashed the truck into a tree, police said. Brown was alone in the truck.

During the chase, Brown drove the wrong way on Interstate 495 in Amesbury and fired shots at police cruisers, according to police.

The shooting is being investigated by New Hampshire State Police and the New Hampshire attorney general. Strelzin did not say how many troopers were involved in the shooting and has not released their names.