A gunman with a violent criminal past shot a police officer in the head before barricading himself inside a home, officials in Washington state said.

A SWAT team and hostage negotiators had been locked in a 7-hour standoff in the city of Mount Vernon before taking the suspect into custody just before 1 a.m. local time (4 a.m. ET), according to police.

Primary suspect taken into custody. Briefing to follow. — Sgt. Mark Francis (@wspd7pio) December 16, 2016

Officers stormed the building using tear gas and detained the 44-year-old local man along with two others, Washington State Patrol Sgt. Keith Leary told reporters.

Authorities initially believed there were hostages, but Leary said the two people other inside the building were also taken into custody as "persons of interest."

He added: "We have our primary suspect, who we know was the person doing the shooting. These other two individuals ... are they hostages? You're getting so much mixed information on what has transpired inside the residence."

No shots were fired by police or the three suspects during the raid, he said.

A map showing Mount Vernon, Washington. Google Maps

The officer shot in the head is a 30-year veteran of the Mount Vernon Police Department. He was hospitalized in a serious but stable condition. "He's hanging in there," Washington State Patrol Sgt. Keith Leary told reporters.

The officer is a husband, a father, a grandfather and also serves his community as a Boy Scout leader, according to NBC station KING 5.

He was one of several officers who responded after a man was shot on a street corner at around 5:30 p.m. local time (8:30 p.m. ET), according to Leary.

When they arrived, the suspect began firing at them and struck the officer in the head. The initial shooting victim was later found to have only been grazed, Leary said, adding it was not clear what prompted that incident.

The suspect then barricaded himself inside a home and Leary told reporters that as of around 10 p.m. local time (1 a.m. ET) "the subject is still shooting at officers" from inside the building.

Authorities closed roads and neighbors were asked to evacuate to the nearby Salem Lutheran Church.

Skagit Valley College, just a block away from the scene of the initial shooting, told students at one of its housing complexes to stay in their dorms, and others to stay away completely.

Update SVC MV Campus : Police activity is ongoing. MV CAMPUS IS CLOSED. CVV students remain in your dorm. Eveyone else AVOID AREA Completely — SkagitValleyCollege (@SVCCollege) December 16, 2016

Leary said the suspect has a "violent past" and is "well known to law enforcement."

He said the house was visited frequently by law enforcement personnel.