Correction: An earlier version of this article misspelled the first name of Alan Nash, the Erath County, Tex., district attorney who is prosecuting the case. This version has been corrected.

Two years ago this month, former Navy SEAL Chris Kyle, the American sniper immortalized in a blockbuster movie, and a friend took a troubled young veteran to a rifle range for some therapeutic camaraderie.

As they drove to the Rough Creek Lodge and Resort, something unsettled Kyle, 38, who quietly texted his friend about the third man, sitting in the back of the Ford F-350: “This dude is straight-up nuts.”

Kyle’s buddy and weightlifting partner, Chad Littlefield, 35, replied, “He’s right behind me. Watch my six,” using military shorthand for “watch my back.”

A short time later, on Feb. 2, 2013, Kyle and Littlefield were dead, shot by Eddie Ray Routh, the 27-year-old Marine Corps veteran they were trying to help.

Opening arguments in Routh’s murder trial began here Wednesday in the Erath County courthouse, as reporters from around the world converged on this small town — which bills itself the Cowboy Capital of the World — to observe it. Kyle’s story as the most lethal sniper in U.S. military history is the subject of both his best-selling memoir “American Sniper” and the Clint Eastwood-directed movie by the same name that has earned nearly $300 million at the box office.

The jury was told that Kyle, 38, was shot five times in the back and side and once in the side of the head with a .45-caliber pistol. Littlefield, 35, was shot four times in the back, once in the hand and once in the head with 9mm Sig Sauer pistol, which was later found reloaded and in Routh’s possession when he was arrested. Both guns belonged to Kyle.

“There was no saving these men,” said Erath Country District Attorney Alan Nash. “Their injuries were too bad. They were beyond saving.”

The foreboding text messages were disclosed Wednesday by the defense as part of a strategy to have Routh found not guilty by reason of insanity. He faces life in prison without the possibility of parole if convicted.

Defense attorney Tim Moore told the court that Routh had been diagnosed with a variety of mental conditions, including psychosis, paranoia, schizophrenia and post-traumatic stress.

Routh, he said, was “in the grip of a psychosis” when he killed Kyle and Littlefield and had come to fear them.

“He thought he had to take their lives or he was in danger,” Moore said.

He told the jury that his client had undergone psychiatric treatment at both Green Oaks Hospital and the Department of Veterans Affairs hospital in Dallas. It was determined on Jan. 19, 2013 — just a couple of weeks before the shooting — that he could pose a danger to others, but the VA hospital nonetheless released him on Jan. 25 with anti-psychotic medicine, Moore said.

A frantic 911 call details the aftermath of the murder of "American Sniper," Chris Kyle. The call comes from the suspect’s sister and brother-in-law. Eddie Ray Routh is accused of killing Chris Kyle and his friend, Chad Littlefield. (Jorge Ribas, Kate M. Tobey and Julio C. Negron/The Washington Post)

Nash, the district attorney, said that although Routh was troubled, he knew what he was doing was wrong when he killed the men. In Texas, if the jury finds Routh had the ability to distinguish between right and wrong, that would preclude a verdict of not guilty by reason of insanity.

“Does mental illness take away the ability to know right from wrong?” Nash asked the jury. “I ask you to consider that.”

He also noted that Routh had consumed whiskey and marijuana, possibly laced with formaldehyde, the morning of the shooting.

The case is likely to focus heavily on Routh’s military background and history of mental illness. His family has said that he suffers from post-traumatic stress disorder as a result of his time in the military, an assertion prosecutors might challenge.

Routh joined the Marine Corps in June 2006 and served four years as a small-arms repairer/technician, including stints in Iraq between September 2007 and March 2008; aboard the amphibious assault ship USS Bataan from May 2009 to December 2009; and in support of earthquake relief operations in Haiti from January through April of 2010, according to military records.

Routh did not receive the Combat Action Ribbon, the Navy Department decoration that would indicate that he had “directly and actively” participated “in ground or surface combat.”

Kyle’s widow, Taya Kyle, testified Wednesday that her husband, drawing on his own experience with PTSD after four tours in Iraq, liked to help other veterans with their transition back into civilian life. She said Routh’s mother had asked Kyle to help her son, and that her husband had never met him before.

After the shooting, Routh stole Kyle’s truck, drove to a Taco Bell for a burrito and then to his sister’s house, where he confessed to the killing, according to court records. “I just murdered two men,” he said.

Kyle teared up at times when describing her last day with her husband. They had two children together, then 8 and 6 years old, and attended one of their basketball games that morning. They parted ways afterward, but planned to meet for dinner with friends that night.

Littlefield was a good friend of Chris Kyle’s who first met the former Navy SEAL at their children’s soccer game, Taya Kyle said.

While Taya Kyle was taking her daughter to build a teddy bear, her husband and Littlefield were at the range with Routh. She called his cellphone, and he sounded unsettled, she told the court.

A lodge employee, Justin Naybors, said he found the two men near each other, with Kyle laying “facedown, his nose in the dirt” near an elevated deck from which rifles are fired. Littlefield was on the deck nearby.

The jury was shown graphic photos of Kyle and Littlefield at the crime scene covered in blood. Family members and at least two of the jurors could be seen wiping tears away.