NEW YORK (AP) — A gun and notebook that prosecutors say link Luigi Mangione to the killing of UnitedHealthcare CEO Brian Thompson can be used as evidence at his murder trial, a judge ruled Monday, rejecting a defense argument that they were seized illegally.

Judge Gregory Carro's decision, five months after he held a hearing to examine how police came upon the items, is a major win for prosecutors, enabling them to show jurors a possible murder weapon and motive. That mirrors an earlier ruling in Mangione's federal case.

But Carro also excluded items officers pulled from Mangione's backpack before his arrest at a McDonald's restaurant in Altoona, Pennsylvania. He said the loaded gun magazine, cellphone, passport, wallet and computer chip resulted from an "improper warrantless search." He also excluded some statements he made to police before he was handcuffed.

The judge did allow items found as officers inventoried the backpack's contents later at a police station — including a 3D-printed pistol prosecutors say matches the one used to kill Thompson, and a notebook that describes wanting to "wack" a health insurance executive. Carro said such inventory searches are an exception to the U.S. Constitution's protections against unreasonable searches and seizures. Police obtained a search warrant hours later.