Early on Saturday, sheriff’s deputies in southwest Virginia received an unusual message. An emergency signal had been sent from a hiker’s GPS device on the Appalachian Trail. So the deputies went into the forest to look for him. As they stopped to talk to other hikers on the trail, a dog wandered up to the group.

The dog led them to its owner, James L. Jordan, who was standing about 30 yards away, according to Sheriff Keith Dunagan of Wythe County, who recounted the events on Monday. Then they found the body of the missing hiker, who had been stabbed to death. A companion of the hiker’s had also been wounded.

That led the authorities to charge Mr. Jordan, a 30-year-old from West Yarmouth, Mass., in federal court on Monday with one count of murder and one count of assault with the intent to murder, the United States Attorney’s Office for the Western District of Virginia said. Mr. Jordan did not enter a plea and was remanded in custody, said Brian McGinn, a spokesman for the office.

Mr. Jordan’s public defender could not be reached for comment on Monday.

The attack on the hiker, who has not been publicly identified, and his companion has unnerved denizens of the hiking world who meander through the wilderness of the 2,190-mile Appalachian Trail from Georgia to Maine. Many members of this disparate, determined and close-knit group yearn to disconnect from the world and find solitude on the trail, but they often depend on an online network of guides and social media groups to keep informed — and to stay safe.