Thomas J. Spota, the Suffolk County district attorney, and his top anti-corruption prosecutor were charged on Wednesday with witness tampering and obstructing a federal investigation into the beating of a suspect by the county’s former police chief.

Criminal charges against a sitting district attorney are rare, but Mr. Spota and his office have been under scrutiny for years, and the indictment on Wednesday was the latest turn in a federal investigation that has transfixed Long Island and led to the downfall of the county police chief, James Burke.

Federal investigators began their inquiry in Suffolk County after the December 2012 arrest of a heroin user named Christopher Loeb, who financed his habit by breaking into cars. By chance, one of the vehicles belonged to Mr. Burke, the police chief. From the vehicle, Mr. Loeb stole a duffel bag that contained cigars, pornographic DVDs and sex toys.

Chief Burke, a protégé of Mr. Spota and a polarizing figure among county leaders, was apparently enraged by the theft.

Four years later, after an investigation by federal agents, Mr. Burke pleaded guilty to having beaten Mr. Loeb after he was arrested and shackled to the floor of a police station. Last year Mr. Burke was sentenced to 46 months in federal prison for assaulting Mr. Loeb and for trying to orchestrate a cover-up of what had happened.

In an indictment unsealed on Wednesday in Federal District Court in Central Islip, N.Y., federal prosecutors accused Mr. Spota, 76, and Christopher McPartland, 51, one of the district attorney’s top deputies, of participating in that cover-up. Federal prosecutors accused them of holding a series of meetings and phone conversations with Mr. Burke and other police officers in which they agreed to conceal Mr. Burke’s role in the assault and to impede the federal investigation.

Mr. Spota remains in office, but he had already announced that he would not seek re-election in November. Mr. Spota has been district attorney since 2002, and he initially earned praise for pursuing corrupt officials in local towns, and for spearheading an inquiry into how Roman Catholic Church officials on Long Island had protected pedophile priests.

Mr. Spota and Mr. Burke had been close for years. They met in the late 1970s, when Mr. Burke, then a teenager, was the star witness in a murder case involving a 13-year-old boy whose body was found with six rocks jammed down his throat. Mr. Spota, then an assistant district attorney, prosecuted the case.

Mr. Burke went on to become a police officer, and after Mr. Spota was elected district attorney he brought Mr. Burke to his office as a top investigator, and later pushed him as a candidate to become the top uniformed officer on the county police force, which is overseen by a civilian commissioner. With Mr. Spota’s backing, Mr. Burke became the chief in 2012.

He was initially a relatively popular figure: a gregarious lawman, complete with mustache and lit cigar, who spoke of bringing modern police management techniques to the department.

But Mr. Burke also launched a number of questionable investigations, some involving dubious surveillance methods. A federal prosecutor in late 2015 described one of his acts — having a GPS device installed on the car of a rival police official — as “something out of the K.G.B.”

And Mr. Burke seemed eager to pick arguments with federal agencies. He withdrew his detectives from a federal task force focused on gangs, a decision that in retrospect is all the more troubling, as M.S. 13 has been blamed for 17 murders in one recent 18-month stretch in Suffolk County.

Investigators, along with the Suffolk County district attorney’s office, at one point spurned help from the F.B.I. amid an investigation into a serial killer who was dumping the bodies of murdered prostitutes along a desolate stretch of roadway near Gilgo Beach.

But it was not one of these high-profile cases that led to his undoing. Instead, it was his decision to confront and rough up Mr. Loeb, the heroin user who had stolen the bag of pornography and sex toys from his car. Initially, Mr. Loeb was prosecuted in Suffolk County, where Mr. McPartland, a high-ranking lawyer in Mr. Spota’s office, handled the case. Later, the prosecution of Mr. Loeb was handed off to a special prosecutor, an assistant district attorney in Queens, who secured a conviction.

Court papers unsealed on Wednesday accuse both Mr. Spota and Mr. McPartland of obstruction of justice and conspiracy to tamper with witnesses. But the papers, filed by federal prosecutors, offer little detailed information beyond accusing Mr. Spota and Mr. McPartland of pressuring several unnamed witnesses to lie to federal agents, to give false testimony under oath, and to withhold information from grand jurors.

“Instead of upholding their oaths, these defendants allegedly abused the power of the Suffolk County district attorney’s office,” Bridget M. Rohde, the acting United States attorney for the Eastern District of New York, said in a statement.

“Tom Spota committed no crime,” Mr. Vinegrad said. “In fact, for many years of a very long and distinguished career, Tom had worked hard to investigate and prosecute crime, and deliver justice to the residents of Suffolk County. Tom categorically denies the government’s charges, and he looks forward to vindicating himself in court.”

A version of this article appears in print on , on Page A20 of the New York edition with the headline: Suffolk Prosecutor and His Deputy Are Charged With Obstruction. Order Reprints | Today’s Paper | Subscribe