A sergeant with an obscure District police agency in charge of security across 33 million square feet of city government office space is on trial this week for possessing a gun that his bosses authorized him to buy.

Sgt. John Barbusin of the D.C. Protective Services Police Department bought the weapon — an AR-15 assault rifle — at a gun shop in Maryland four years ago. He kept it in his apartment in Northeast Washington until D.C. police learned of it in 2011, raided his house and charged him with possessing an unregistered firearm and other counts.

Barbusin bought the gun after the chief of his agency announced plans to form a SWAT team armed with high-powered semiautomatic weapons. Top commanders authorized the purchase to help Barbusin train, and a deputy chief provided a letter stating that the rifle was for the “performance of official duties” to bypass federally mandated background checks and a 30-day waiting period.

The AR-15 was never stored in any police office; nor was it used on duty. The Protective Services Police Department’s plans to form a tactical squad, meanwhile, were stopped years ago by city leaders. Prosecutors say Barbusin sought and used the authorization letter to expedite a purchase intended for personal use.

But the prosecution of Barbusin has prompted accusations that the D.C. police are waging a petty turf battle against a smaller police agency. It has also called attention to the quantity of such agencies in Washington, the scope of their powers and whether their officers should be allowed to possess weapons in a city with some of the most restrictive gun laws in the country.

Barbusin has been suspended since his arrest two years ago. He has refused a plea bargain, and prosecutors have refused to drop the case.

Barbusin’s attorney, J. Michael Hannon, said the episode began in 2009 when Lou Cannon, then the chief of the Protective Services Police Department, announced plans to start a SWAT team to address growing concern about workplace violence and domestic terrorism.

According to a general order Cannon issued at the time, he was seeking volunteers to get “additional training in emergency response in handling these potentially volatile situations,” including “active shooters or individuals believed to be armed.” There was some cause for concern: In 1977, a gunman took hostages in what was then called the District Building, or city hall, killing a reporter and wounding three men, including Marion Barry, who was a council member at the time.

Hannon said his client and a colleague bought assault weapons after seeing them in a gun shop. The other officer called the AR-15 his “dream weapon,” the lawyer said, and the clerk told them that the authorization letters would quicken the sale. Hannon said the deputy chief signed off because the purchase coincided with efforts to form the tactical team. The colleague brought his rifle home to Maryland.

But Cannon was pushed out of his job, and city leaders put a stop to the SWAT team idea. According to Hannon, “a philosophical change occurred somewhere in the government, and they got rid of the chief and eviscerated the changes that he made.”

Authorities declined to discuss the case because of the trial, although one top police official said Barbusin and his assault weapon were targeted only to enforce the law.

City officials said there are no plans to let Protective Services officers carry assault weapons at the 67 District-owned or -leased properties, which include water-treatment plants, libraries, the John A. Wilson Building and Nationals Park.

The D.C. Attorney General’s Office, which is prosecuting the case, contends that the 484 members of the protective force are not real police officers. Managed out of the city’s real estate office, they are basically security guards, authorities said, commissioned to make arrests and carry handguns but with power limited to the properties to which they are assigned. The officers are prohibited from using any weapons other than 9mm Glocks, provided by the D.C. police, and a few shotguns.

Cannon, the former police chief, later acknowledged that the authorization letter was inaccurate because the weapon was intended for personal use, according to court documents. Another commander within the agency testified that no one in Protective Services was authorized to carry an AR-15.

Yefat Levy, a prosecutor with the D.C. Attorney General’s Office, argued in a motion that Barbusin shouldn’t have been allowed to keep the gun unless he was “issued this firearm by his employing agency,” had authorization to carry it on duty and had it registered with the D.C. police. None of those criteria were met, Levy said.

Hannon said the security officers are real police officers as defined under federal law, meaning the authorization letters they obtained in 2009 give them the legal right to possess the assault weapons, even in the District. He also said it doesn’t matter that Barbusin’s gun was never used in the line of duty.

Barbusin’s trial began last week but stalled Thursday when the defense accused prosecutors of withholding information about e-mails by the former chief.

D.C. Superior Court Judge Stuart G. Nash suggested to prosecutors that on Monday he would consider throwing out two of the gun charges — possessing the weapon and ammunition. That would leave Barbusin charged with possession of a gun magazine holding 10 or more rounds, which is illegal for civilians.

“I think the government has a very deep hole to try to dig out of in terms of ultimately persuading me to convict Sgt. Barbusin,” Nash said, according to a transcript. Of the gun-clip charge, he said, “I would find it personally distasteful to have to convict and sentence him for doing what every other law enforcement officer in the District of Columbia does and is not prosecuted for.”