TRENTON -- New Jersey's highest court on Thursday threw out weapons charges against an Atlantic County man, finding local police violated his constitutional rights by illegally entering his home during a routine investigation.

The state Supreme Court ruled 6-1 that a Somers Point police officer did not have probable cause to follow James L. Legette into his apartment after responding to a noise complaint at his building in January 2012.

The court found the officer should have stayed out of the apartment because he was conducting an investigatory stop rather than an actual arrest.

A spokeswoman for the state Public Defender's Office said the decision reaffirms constitutional protections against unreasonable search and seizure.

"What we are talking about here is an officer who followed a man into his home without consent and without placing him under arrest," the spokeswoman, Jennifer Sellitti, said in an e-mail.

According to court records, Somers Point police officer Richard Dill came upon a common porch area in the building while investigating the noise complaint, claiming he heard music and loud voices and detected the smell of burnt marijuana.

The officer encountered Legette and asked him for identification, but Legette told him his ID was up in his apartment, according to the court record.

Legette offered to go get his ID, but the officer told him "he would have to accompany him to his apartment under the circumstances," the documents show. Legette did not respond and continued up the stairs. The officer followed.

Dill said he noticed a bulge in the man's sweatshirt, and after entering his apartment and handing the officer his ID, Legette removed the sweatshirt and handed it to a woman in the apartment, telling her to put it in the bedroom, the records show.

Dill, who was calling in to headquarters over his radio in order to check for warrants, told Legette "he would need to examine the sweatshirt."

The officer then followed Legette into his bedroom as the man grabbed another sweatshirt from a closet. Dill picked up the sweatshirt Legette had been wearing from the floor.

The officer noted he appeared "visibly nervous."

Dill told Legette he would be cuffed and detained while the officer investigated, according to court records. The warrant check, meanwhile, came up empty.

Legette refused to consent to a search of the sweatshirt, so the officer placed it on the ground alongside another sweatshirt and a towel and brought in a drug-sniffing dog.

"The dog put his nose in defendant's sweatshirt, grabbed it in its mouth, and dropped it onto the pavement," according to court records. "The sweatshirt made a clanking noise as it hit the ground."

Inside, the officer found a loaded handgun. Legette was charged with unlawful possession of a handgun without a permit and possession of a weapon by a felon.

At trial, Legette argued the evidence against him was inadmissible.

According to court records, prosecutors conceded on appeal that the search and detention went beyond what was necessary to investigate whether Legette possessed marijuana.

But they argued the evidence was admissible under the "theory of inevitable discovery," claiming that while the officer didn't follow procedure, he would have found the gun anyway if he had.

In his dissent, Justice Lee Solomon also argued Dill had probable cause to arrest Legette over the smell of marijuana. He wrote that protections given to police officers to perform searches of arrestees in such a case should also extend to cops detaining someone during an investigation.

Writing for the majority, Justice Faustino Fernandez-Vina found the officer's warrantless entry was "improper, and the evidence seized as a result of that unlawful entry should be suppressed."

Sellitti, of the Public Defender's Office, applauded the decision, noting that the constitution guarantees "a person's home deserves the utmost protection from unreasonable and unwanted intrusion."

A spokesman for the Attorney General's Office, which argued the case on behalf of police, declined to comment on the ruling. The police chief in Somers Point did not respond to a message seeking comment.

S.P. Sullivan may be reached at ssullivan@njadvancemedia.com. Follow him on Twitter. Find NJ.com on Facebook.