AMITY — A fingerprint and DNA from a beer can and cigarette butt led investigators to a man who confessed to killing two men and a boy in a small town on the Canadian border, police said Friday.

Thayne Ormsby, 20, of Orient was arrested Friday in Dover, N.H., where he was held on a fugitive from justice charge, a state police spokesman said. He’s charged in Maine with three counts of murder in the stabbings of a man he thought was dealing drugs, as well as the man’s 10-year-old son and a neighbor, according to an affidavit.

A 911 call on June 23 led police to the body of Jesse Ryan in his father’s mobile home. Investigators then found the body of 55-year-old Jeffrey Ryan in a shed and the body of 30-year-old neighbor Jason Dehahn in a ditch, the affidavit said.

The boy was visiting his divorced father, who had picked him up in Lewiston and brought him to northern Maine for Father’s Day, the affidavit said.

On Friday, residents were relieved that there was an arrest, but they also expressed disbelief because of the savagery of the attacks and the age of the young victim in a quiet community where homes are sometimes separated by miles of woods, said resident Debby Cone.

“Everybody is pretty much in a state of shock,” Cone said. “A triple homicide, a murder of a 10-year-old boy? It happens in big cities. It doesn’t happen out here.”

The only reason Ormsby gave for the killings in the initial interview in New Hampshire was that he thought “Jeff Ryan is a drug dealer,” state police Detectives Joshua Haines wrote.

State police Lt. Thomas Kelly said the investigation was continuing. On Friday, a pair of search warrants were being executed by detectives in the Amity and Orient area, but police declined to say what was being sought.

The state police investigation led them to question Ormsby and investigators zeroed in on him after he voluntarily provided fingerprints and DNA samples. The DNA and a fingerprint matched a beer can and DNA matched a cigarette butt, both found at the scene of the killings, an affidavit said.

Extradition proceedings will be held on either Tuesday or Wednesday in New Hampshire, said Stephen McCausland, spokesman for the Maine Public Safety Department.