The Connecticut Supreme Court ruled Thursday in a murder case that police were justified in entering the defendant's home without a warrant after observing an infestation of flies at a window.

The ruling comes in the case of Andrew Samuolis, who is serving a 45-year sentence for murdering his father with a modified flare gun in February 2013 and shooting an officer in the arm months later when police entered his Willimantic home.

The court agreed with Samuolis' lawyers, who argued that a warrant was needed for police to go into the home to check on the well-being of the son, who was known to have mental issues, or if officers believed there was a dead body in the house.

CONNECTICUT HIGH SCHOOL LACROSSE MURDER: POLICE ANNOUNCE ARRESTS OF THREE MORE TEENS IN JAMES MCGRATH CASE

But the justices found that police could have believed the father needed emergency attention, allowing for an exception to the warrant requirement of the Fourth Amendment to the U.S. Constitution.

Andrew Samuolis

Andrew Samuolis listens to Connecticut state prosecutors during his sentencing. The Connecticut Supreme Court ruled Thursday in a murder case that police were justified in entering the defendant's home without a warrant after observing an infestation of flies at a window.  (Aaron Flaum/The Norwich Bulletin via AP)

"Although the responding officers thought, based on their experience, that the most likely explanation for this fly infestation was the presence of a dead body, they also left open the possibility that an occupant might be injured rather than dead," Justice Christine Keller wrote for the court. "We cannot say that this supposition was unreasonable."

CONNECTICUT MOM STRANGLED 3 KIDS BEFORE HANGING HERSELF IN SHED IN APPARENT TRIPLE MURDER-SUICIDE: COPS

Police were doing a second well-being check at the home in June 2013 after being called by neighbors, who had not seen the father, 67-year-old John Samuolis, in months.

After calling out and knocking at the door, police entered the home without a warrant, noting changes from a prior visit, including chicken wire around some of the windows and a fly infestation.

The younger Samuolis appeared in camouflage and shot one officer in the arm before fleeing the home. He was captured after a short manhunt.

A search of the house led to the discovery of John Samuolis' decomposing body in a sealed bedroom.

CONNECTICUT FISHERMAN CATCHES 26-POUND TIGER MUSKIE: 'WHAT A MONSTER!'

Prosecutors said the younger Samuolis had shot his father in the head during an argument over plans to sell the home. He later sealed the body in the bedroom after it began to smell, prosecutors said.