Updated

An accidental 911 pocket-dial sparked a police raid of an underage drinking party at a home in Maine, and a later episode at the same house where a SWAT-like unit confronted an agitated man with a gun holed up in the attic.

York Police said they received a 911 hang-up call early Sunday and heard yelling and arguing on the other end of the line.

“The butt dial was the reason for our involvement,” Sgt. Luke Ernenwein told the Portland Press Herald, saying police responded because they believed someone was in danger.

Using cellphone towers, authorities tracked down the site of a call – and homeowner Leighlon Anderson, 45, met them in the driveway to apologize when squad cars rolled up.

Police said they found an underage drinking party going on at the home and charged Anderson with furnishing and allowing minors to consume alcohol.

But the wild night wasn’t over yet.

Less than an hour later, police got a call a male pointed a gun at one of the minors at the party, the Portland Press Herald reported.

Cops evacuated the home and surrounded it while waiting for the Southern Maine Special Response Team to arrive. They determined Joseph David Coreau, 36, of Kittery, was holed up in the attic, officials said.

Those who fled the house said Coreau was angry about the prior “butt dial.”

The allegedly enraged partygoer eventually left the attic and was arrested before backup arrived.

Cops found three loaded guns in the home’s attic, the Portland Press Herald reported.

“Great job done by all the officers involved. It ended the way we like it to end, with nobody getting hurt,” the York Police Department said on its Facebook page.

Coreau was charged with criminal threatening with a dangerous weapon and is being held in York County Jail on $5,000 bail.