The 14-year-old accused of killing four people at his Georgia high school this week had switched middle schools and drawn the attention of authorities who suspected he had posted school shooting threats online.

His mother had repeated encounters with law enforcement and had been ordered to stay away from drugs and alcohol. His family had been evicted from their home because of unpaid rent, and his parents had split.

Interviews with relatives and others who knew the teenager, and a review of court documents and law enforcement records, reflected a family in constant turmoil in the years before the shooting this week at Apalachee High School in Winder.

The suspect, Colt Gray, has been charged with four counts of murder for the Wednesday morning attack in which two students and two math teachers were killed and eight other students were injured. During his first court appearance on Friday, a judge informed him that he could face a maximum penalty of life in prison.

His father, Colin Gray, is facing second-degree murder and other charges, as officials argue that he shoulders considerable blame for giving his son the AR-15 semiautomatic rifle used in the attack. The weapon was a Christmas gift last year, according to three law enforcement officials. Mr. Gray, 54, faces a maximum sentence of 180 years in prison, if convicted.

During the brief hearing on Friday, relatives of the people who were killed sat directly behind the defendants, only a few feet away. The grief that the community in Winder is now wrestling with was palpable.