A North Carolina man pleaded guilty Friday to fatally stabbing his 6-year-old daughter as national park rangers approached rather than give up custody of the girl.

Seth Willis Pickering, 38, of Leicester, is expected to spend the rest of his life in prison after pleading guilty to first-degree murder for killing his daughter in September 2016, federal prosecutors said. Two national park rangers said he stabbed Lila Pickering in the heart and lung as they were walking toward him to talk along the Blue Ridge Parkway in North Carolina.

"Now they will never be able to take her away from me," Pickering later told a ranger, according to an affidavit filed by an FBI investigator. It added that he also said something to the effect of "she's happier now. ... It's what she wanted."

Lila had been in protective custody for a month when her father, who was allowed to see his daughter in supervised visits, took her from the home over the objections of her temporary caretaker. The first-grader had previously lived with Pickering. It's unclear why social workers removed Lila from her father's care and placed her in the home of a classmate.

Lila's mother, who is Pickering's estranged wife, lived in Florida at the time.

Pickering's plea agreement states that he will be sentenced to life in prison without possibility of parole, sparing "the family the trauma of a lengthy trial and decades of appeals," U.S. Attorney R. Andrew Murray said in a statement.

Pickering, clad in a baggy brown jumpsuit and chains, declined to make a statement Friday before U.S. District Judge Max O. Cogburn Jr. accepted the plea agreement, the Citizen-Times of Asheville reported. Defense attorneys S. Frederick Winiker and Mary Ellen Coleman declined to comment after the plea deal was accepted.

Winiker said Pickering has been treated for mental illness in the past and is taking a prescription drug used to treat symptoms including depression and obsessive-compulsive disorder, the newspaper reported. Pickering also had been treated for alcohol abuse a month before he killed his daughter, Winiker said.

His estranged wife, Ashley Pickering, told the Citizen-Times in 2016 that she had since been fighting for custody of Lila after moving to Florida, adding that Seth Pickering was a doting father and Lila idolized him.

Pickering won a restraining order against Ashley Pickering in 2015 after alleging that she threatened him and the child.

Rangers approached Seth Pickering and his daughter near nightfall on the day of the slaying after noticing a car parked along the scenic parkway, part of the National Park System.

The rangers noticed a man and young girl walking down an embankment in an area with no trails, picnic areas or designated campsites less than an hour after Pickering took his daughter from her custodian's home without permission, the FBI agent's affidavit said. Pickering had built a small fire with underbrush that he cut before the rangers approached to investigate the illegal campfire and other possible violations.