A Kittery man has been sentenced to 38 months in prison for having a gun while being subject to a protection order.

Zachary Spinney, 36, will also be subject to three years of supervised release.

He was sentenced Friday in U.S. District Court in Portland by Chief Judge Nancy Torresen. Spinney pleaded guilty to the charge in November.

According to the U.S. Attorney’s office, Spinney and his girlfriend bought a Ruger semi-automatic rifle and more than 180 rounds of ammunition from a firearms dealer in July. He was prohibited from possessing a firearm because of a March 2016 protection from abuse order that had been issued in Maine.

Torresen imposed a sentence that was five months longer than federal guidelines after hearing testimony on Spinney’s history of domestic violence.