AUGUSTA, Maine — A Maine man confessed to a friend after shooting a sheriff's deputy in the head last week, investigators said in documents made public Monday.

A state police affidavit was filed as 29-year-old John Williams made his initial court appearance on a murder charge. Williams, who was ordered held without bail, is charged with killing 61-year-old Somerset County Cpl. Eugene Cole in Norridgewock.

Lisa Marchese, chief of the criminal division of the attorney general's office, said the state is going to seek a life prison sentence. The case will be presented to a grand jury in the next month or so, she said. A court-appointed defense lawyer told reporters that he wasn't ready to discuss specifics of the case.

The affidavit stated that a police vehicle — it didn't specify whether it was Cole's — appeared as friends were dropping Williams off in front of a house early on April 25. Cole's body was later found outside the home. The friends described Williams as antsy and having body armor with him.

After killing Cole, Williams stole the deputy's cruiser and stole cigarettes from a convenience store before abandoning it, the affidavit indicated.

Another friend said he met up with Williams after the shooting and that the two smoked drugs using a "crack pipe." That same friend said he saw a shotgun in the trunk of a car that dropped off Williams at one point early Wednesday, according to the affidavit.

One friend says Williams confessed in a cell phone call, but the affidavit didn't point toward motive. Friends said he had been frustrated by his arrest in Massachusetts the previous month and by his girlfriend's arrest in Maine days earlier — in which Cole had been involved.

Williams was due in court in Massachusetts the day of the shooting and had talked to a friend about becoming a fugitive.

Williams was not required to enter a plea Monday, and a judge ordered him held without bail. Williams stared ahead and quietly answered the judge's questions. The judge ordered a mental health evaluation and, at the request of attorneys, moved future court proceedings from Somerset County to Portland to ensure that Williams gets a fair trial.

After the hearing, Williams returned to the state's maximum security prison, the Maine State Prison in Warren. Prison officials said it was not an unusual arrangement for an inmate with special security needs.

Several of Cole's family members, including his wife and son, attended the hearing but left without talking to reporters.

Cole's wife, Sheryl, posted on Facebook to thank people for their kindness and law enforcement officials for their service.

She said her husband talked about the "crazies" being out on the night he was killed, but that nothing seemed to be out of the ordinary when he headed out to work.

"We said our ritual goodbye, ending with me saying (or yelling) 'be safe' and him responding 'absolutely,'" she wrote. "The next time I saw my husband, he was lying in a casket."

Cole's killing prompted a massive manhunt with more than 200 law enforcement officers pouring into the area in central Maine, along with tactical vehicles and helicopters.

Williams was arrested outside a remote cabin Saturday, the fourth day of a massive manhunt in the region. He was shirtless and shoeless when he was captured and appeared exhausted when he was led out of the woods.

Colleagues of the 61-year-old Cole, meanwhile, praised him as a kind and patient deputy, one who was known for defusing volatile situations and treating those he arrested with respect.