NEW YORK (AP) — Sheldon Silver, the former New York Assembly speaker who brokered legislative deals for two decades before corruption charges abruptly ended his career, was sentenced Friday to seven years in prison.

The punishment, announced by U.S. District Judge Valerie Caproni, was five years less than the 12-year sentence she gave to Silver after he was initially convicted in the case in 2015.

That conviction was tossed out by an appeals court, but the 74-year-old Democrat fared no better at a second trial this spring. A jury once again found him guilty of taking nearly $4 million in return for legislative favors he performed for a cancer researcher and real estate developers.

In a letter to the judge, Silver had begged for mercy. His lawyers had asked that he be given a shorter sentence with a community service component that would allow him to get out from behind bars.

"I pray I will not die in prison," Silver wrote, saying he was "broken-hearted" that he damaged the trust people have in government.

"The work that has been the focus of most of my life has become dirty and shameful," Silver had said in his letter. "Everything I ever accomplished has become a joke and a spectacle. ... I beg for your mercy so that I can somehow go out into the world again to atone to everyone I have hurt."

Prosecutors had argued that Silver "repeatedly corrupted the great power of his office for personal profit" and should get at least a decade in prison.

First elected in 1976, Silver served as speaker for 21 years, resigning after his 2015 arrest.

His sentencing comes 10 days after Dean Skelos, the former New York Senate leader, and his son, Adam, were convicted of extortion, wire fraud and bribery at a retrial for each of them.

More From WIBX 950