Thomas Latanowich, right, is lead out of court after he was sentenced Friday in Barnstable Superior Court in Barnstable, Massachusetts. Credit: Steve Heaslip / Cape Cod Times via AP

BARNSTABLE, Massachusetts — A man described by prosecutors as a career criminal was convicted Friday of killing a Massachusetts police officer who was helping serve an arrest warrant at a Cape Cod home in 2018.

After nearly three full days of deliberations, a jury found Thomas Latanowich, 32, of Somerville guilty of second-degree murder in the fatal shooting of Yarmouth police Sgt. Sean Gannon.

Gannon, 32, the department’s K-9 officer, was killed in April 2018 while he and other officers were serving an arrest warrant at a Barnstable home for a possible probation violation. Gannon’s dog, Nero, also was shot but survived.

The jury started deliberating on Tuesday afternoon  after a roughly two-week trial in Barnstable Superior Court.

Latanowich and his lawyer, Joseph Krowski Jr., had argued the defendant did not know Gannon was a police officer when he opened fire.

Latanowich took the stand in his own defense during the trial to tell jurors he had been dealing drugs and was “scared” after someone shot at him just days before. He said he went to the Cape Cod home, which belonged to a friend, to evade the person who was after him.

“Thomas Latanowich didn’t arm himself with a gun so he could shoot police,” Krowski said during closing statements. “His state of mind is that the people who were going to kill him are there.”

Krowski said police botched the operation to detain Latanowich, and that there was no clear chain of command.

Prosecutor Michael Trudeau disputed the defense’s account of events. “This is not a debate of police policy and procedure,” he said in closing statements. “Nor is it a case of a mysterious, roving gang bent on killing, ladies and gentlemen. And it is definitely not a case for self-defense.”

Police had clearly announced their presence at the home, Trudeau said, announcements that a contractor working at a home next door heard. Latanowich also sent voicemail and text messages to his ex-girlfriend after the shooting, in which it was clear he knew he had shot a police officer, prosecutors said.