Former Philadelphia Sheriff John Green was sentenced to five years in prison Thursday after pleading guilty to selling his position running an office that critics have long said was corrupt, dysfunctional, expensive, and unneeded.

Green, 71, was the longest-serving sheriff in Philadelphia history, holding the elective office from 1988 to 2010. A Democrat, he oversaw an agency that transports prisoners to court, maintains courthouse security, and conducts sheriff’s sales of real estate foreclosed on for unpaid taxes or mortgages.

Prosecutors said he extracted more than $675,000 in bribes, kickbacks, and other benefits — ranging from a secret job for his wife to massive amounts of illegal campaign contributions — in exchange for giving $35 million in no-bid work to a businessman who became the office’s biggest vendor.

“I accept full responsibility for my actions, your honor, and I am sorry,” Green said in brief remarks to U.S. District Judge Wendy Beetlestone. She sentenced him to the maximum applicable term for his plea to one count of conspiracy to commit fraud.

Good-government groups have long criticized the sheriff’s position, created in 1838. David Thornburgh, president of the Committee of Seventy watchdog group, reiterated Thursday his organization’s view that the office should go the way of the old Philadelphia Traffic Court or the Clerk of Quarter Sessions’ office and be abolished.

“This is a story of an elected Philadelphia official who misused his office,” Thornburgh said. “But it’s made clear that this is an obscure office that doesn’t need to exist.” The work of the office “could easily be performed by another part of city government,” he said.

Green, a former Philadelphia police officer, first won office as an outsider running without the support of the Democratic Party machine and promising to end the favoritism and incompetence seen under the last sheriff. To some, Green was a progressive, winning national attention for imposing a temporary moratorium on sheriff’s sales to help distressed homeowners.

But he quit office abruptly midterm in 2010, amid negative media coverage about sweetheart contracts, and a bruising battle with the City Controller’s Office over its attempt to scrutinize Green’s official spending. Former Controller Alan Butkovitz on Thursday called his office’s scathing 312-page report “the major accomplishment” of his dozen years as controller; the 2011 document anticipated much of the federal case brought against Green in 2015.

In sum, U.S. prosecutors said he had sold the office to secret benefactor James R. Davis, permitting him, often without written contracts, to advertise and run the office’s foreclosed-property sales. In return, Davis plied the sheriff with bribes and illegal campaign contributions.

Green and Davis stood trial together last year. The jury convicted Davis of fraud and income tax offenses, but acquitted Green of three charges and deadlocked on two others. Green’s lawyer later said that the prosecutors, after talking with jurors, told him the 12-member panel would have convicted Green on the deadlocked counts except for one holdout.

This April, in a surprise development just days before his retrial on the deadlocked charges, Green worked out a deal with prosecutors to plead to just one of the two counts and thus face only the maximum sentence of five years. He did so not long after Davis, 68, was sentenced to 10 years.

Among other illegal payments, Davis poured $210,000 into Green’s last campaign, paying for ads and “street money” to workers on Election Day — far exceeding the limits in city law that capped donors to a $2,500 contribution per election.

Davis also hired Green’s wife and paid her $89,000 over six years, money to the sheriff’s household that Green never disclosed to the public on required forms.

The businessman bought and renovated a Philadelphia home for Green, selling it to him at a $39,000 loss. Davis also gave the sheriff a no-interest $258,000 loan for a retirement home near Orlando, Fla.

Taxpayers paid Green a $118,000 salary in his final year in office.

Green was a lonely figure in court Thursday, accompanied only by his attorney, Peter J. Scuderi. The defense lawyer told the judge that Green had just sold his Florida home to raise $76,000 to pay a forfeiture levy imposed as part of his conviction. He said the former sheriff was broke and could not immediately pay an additional $17,000 fine imposed Thursday by Beetlestone.

“Give him a little bit of a break,” Scuderi pleaded, asking for a sentence of less than five years.

Assistant U.S. Attorney Sarah L. Grieb, who brought the case against Green with fellow prosecutors Christopher Diviny and Jennifer A. Clarke, said Green already had gotten his break with the plea deal. In particular, she said, Green violated the trust of people facing foreclosure by slamming them with high fees used to funnel money to Davis.

“There is real harm in this case,” Grieb said. “Every dollar from the proceeds of the sale was important to them.”

After Green stepped down, he was succeeded in the next election by Democrat Jewell Williams, whose tenure has been clouded by news of sexual-harassment lawsuits, one of which was settled for $127,500 last year and another which he continues to fight in court. A third sexual-harassment lawsuit filed against Williams in 2011 when he was a state representative from the 197th District in North Philadelphia was settled in 2012 for $30,000.

Federal prosecutors have continued to probe the 400-employee Sheriff’s Office in a multiyear investigation that so far has netted four convictions for schemes in which businessmen paid bribes to obtain properties at sheriff’s sales.

Williams also kept up a practice, begun by Green, of spending millions of dollars buying ads for sheriff’s sales in community newspapers, far more than legally required. Some of the newspapers were obscure, and some were owned by people with ties to the Democratic Party. Advocates for people losing their homes to foreclosure complained that the high ad costs wasted funds that otherwise would go to the distressed sellers.

Williams was defeated for renomination by former Philadelphia police officer Rochelle Bilal in the Democratic primary this year. No one sought the Republican nomination in the primary, and her election in the fall seems assured.

Bilal retired from the Philadelphia police in 2013 amid an investigation into a second job she held for a year as public safety director for a borough in Delaware County. Bilal said she kept the two jobs separate and was not double-dipping.

In a 2009 report, the Committee of Seventy said that the Sheriff’s Office “should die,” along with other so-called row offices filled via citywide elections: the Register of Wills and the three City Commissioners who oversee elections.

“There’s no good reason for political independence” for the Sheriff’s Office, Thornburgh said. “There is for the district attorney. There is for the city controller. But there isn’t with this office.”