HARRISBURG — Former Pennsylvania Treasurer Rob McCord was sentenced to 2½ years in prison Tuesday for attempting to use his public office to strong-arm political contributors during his failed gubernatorial campaign in 2014.

McCord, 59, was tearful as he addressed U.S. District Judge John E. Jones III shortly before the sentence was announced. The former treasurer, who will report to prison in late October, also must pay a $5,200 fine.

"I do want to apologize again — I want to apologize to the people of Pennsylvania, to the court, to my really great colleagues at Treasury," McCord said, his voice cracking as he addressed Jones and a courtroom packed with friends and family, including his two sons.

"I broke the law," the Democrat from Montgomery County said, adding that what he did "was not only illegal, it was wrong. I feel horrible remorse about that."

In handing down the sentence, Jones described McCord as "dichotomous" and a "paradox" — a man capable of much good, but who became so fixated on his quest to become governor that he was willing to abuse his power.

"What I see before me is that, unfortunately, Mr. McCord, you used your position as treasurer to further what really became an obsession, an avaricious ambition to become the governor," Jones told McCord, who bowed his head slightly as he listened.

Added Jones: "When an individual's ambition trumps his or her good judgment and their otherwise good character, that's when crimes happen. … You were almost hysterical to raise funds. … It trumped any fiber of reasonable judgment that you had left."

McCord's 30-month sentence appeared to bring to an end what once was described as the most ambitious public corruption probe to come out of Harrisburg in years, a probe that also ensnared another former state treasurer, Barbara Hafer, as well as the onetime chief of staff to Gov. Rendell, John Estey. The investigation spanned years, as onetime top political figures including McCord agreed to secretly wear recording devices for conversations with other insiders.

The question before Tuesday's sentencing was how strongly federal prosecutors would advocate for McCord to receive credit for that cooperation, which also included a turn as the star government witness in the pay-to-play trial last year of a Chester County businessman.

In the end, they did request leniency. But they tempered the request by noting that McCord had not fully owned up to the impact of his "corrupt actions" on his decision-making as a public official.

"He corrupted a watchdog agency," said Assistant U.S. Attorney Michael Consiglio. U.S. Attorney David J. Freed put it this way: "McCord's official actions to benefit his friends and punish his foes compromised the integrity of the Treasury and directly damaged the citizens of Pennsylvania."

After Tuesday's hearing, a visibly relieved McCord hugged his friends and family, but did not speak to reporters. He is expected to turn himself in to federal authorities Oct. 29.

His lawyer, Robert E. Welsh, has said that McCord in recent months has been living in North Carolina, taking classes and teaching yoga. McCord also is studying to become a marriage counselor, according to testimony at Tuesday's hearing.

Prosecutors had recommended that McCord receive a prison sentence of 37 to 46 months, a reduction from the federal guidelines, citing his cooperation. But Welsh had argued that McCord deserved more credit, noting he took responsibility for his misdeeds and agreed to cooperate in other cases.

"That is a really, really difficult decision," Welsh said, noting that the type of cooperation McCord provided would lead to his being "reviled and hated."

In addition, Welsh said, it is important for authorities to provide incentives for future cooperating witnesses.

McCord abruptly resigned his position and pleaded guilty in 2015 to attempted extortion. A year earlier, federal authorities had secretly recorded him attempting to shake down campaign donors for contributions in the 2014 primary for governor. In one instance, he threatened the managing partner of a Philadelphia law firm if it did not make a sizable contribution to his campaign.

"At the very least, I'm still gonna be the freakin' treasurer," McCord told the partner in a conversation recorded by federal agents or cooperating witnesses, the court records show.

McCord agreed to cooperate after prosecutors confronted him with his own words captured in 2,000 wiretapped conversations. For several weeks in late 2014, McCord, for the FBI, secretly recorded conversations with Richard Ireland, a wealthy Chester County businessman and Republican campaign donor. Federal prosecutors charged Ireland with attempted bribery.

But McCord's erratic and unpredictable performance as a key government witness during Ireland's trial last year dealt the investigation its harshest blow and was cited by Jones in his unusual decision to throw out the case mid-trial.

"That wasn't my first rodeo either, and what I saw clearly indicated to me that for whatever reasons … [McCord] was not entirely forthcoming in his testimony," Jones, who presided over the Ireland trial, said Tuesday.

Prosecutors had accused Ireland of attempting to bribe McCord with campaign donations, as well as a promised job in the private sector, in exchange for help in landing state contracts.

But McCord was reluctant to admit he had done anything wrong, insisting he never thought that his dealings with Ireland involved a "this for that" arrangement.

McCord had faced a range of 57 to 71 months in prison under federal guidelines, according to recent court filings.

Five character witnesses testified on behalf of McCord, including his older brother Geoffrey Sayre-McCord, who teaches philosophy at the University of North Carolina, Chapel Hill.

Sayre-McCord said that his brother accepted responsibility without excuse, whereas many public officials cover up their bad acts.

"I've watched him deal with the calamitous effect of his own actions," Sayre-McCord said, including the collapse of his marriage and his professional life.

But he said his brother hasn't been "moping and dealing in self-pity … He has found a path" that includes working to help others.

Jones, in sentencing McCord, closed with these words: "There is redemption. I think you understand that now. I think you've achieved some measure of that."