AUGUSTA, Maine — Maine’s attorney general has concluded that a Farmington police officer was justified in using deadly force in a shooting last November that killed an ex-Army Ranger who confronted him with a knife.

Justin Crowley-Smilek, 26, was fatally shot on Nov. 19 in front of the Farmington Town Hall by Farmington police Officer Ryan Rosie after Crowley-Smilek came at him with a butcher knife.

Crowley-Smilek, who served in Afghanistan, suffered from combat stress and physical injuries from service and had been ordered to seek treatment shortly before the armed confrontation with police.

In a report issued Monday, Attorney General William J. Schneider concluded that when Rosie fired his weapon at Crowley-Smilek, “it was reasonable for Officer Rosie to believe that deadly force was imminently threatened against him, and it was reasonable for Officer Rosie to believe that it was necessary for him to use deadly force to protect himself from the imminent threat of unlawful deadly force posed by the actions of Mr. Crowley-Smilek.”

Crowley-Smilek’s death led to the passage of a law that creates a special treatment court for veterans suffering from drug addiction and mental illness.

The bill, sponsored by Rep. Maeghan Maloney, D-Augusta, was presented in memory of Crowley-Smilek, who returned from Afghanistan with post-traumatic stress disorder and was shot and killed after he threatened Rosie with a knife.

Crowley-Smilek had been in and out of court several times, including the day before his death, when he was ordered to seek psychological help.

Shortly before the shooting, Crowley-Smilek turned up at the town’s police department and asked to speak with a police officer, according to Schneider’s report.

Crowley-Smilek refused to provide his name and said that “there had better be two officers.” When Rosie went to the front entrance, he saw a man later identified as Crowley-Smilek walking away.

Rosie tried to engage Crowley-Smilek in conversation, but the veteran initially did not respond and continued to walk away toward the street. He then “stopped walking, turned around and, with his hands in his coat pockets, started walking at a brisk pace straight toward Officer Rosie. He did not speak. Officer Rosie did not know the man,” Schneider wrote.

Crowley-Smilek continued walking toward the officer, ignoring demands that he take his hands out of his pockets. As Rosie took cover behind his police cruiser, Crowley-Smilek took a butcher knife out of his coat pocket and “held the knife out at arm’s length in front of his body in a threatening display toward Officer Rosie as he continued moving toward the officer,” the report said. Rosie shot Crowley-Smilek after he charged at him.

“Whether deadly force by a law enforcement officer is reasonable is based on the totality of the particular circumstances, and must be judged from the perspective of a reasonable officer on the scene, allowing for the fact that police officers are often forced to make split-second decisions about the amount of force necessary in a particular situation,” Schneider concluded.

“The analysis requires careful attention to the facts and circumstances of a particular case, including the severity of the crime at issue, whether the suspect poses an immediate threat to the safety of officers or others, and whether the suspect is actively resisting arrest or attempting to evade arrest by flight,” he said.