It was hardly a secret that Herman D. Farrell Jr. had planned to retire from the New York State Legislature. The governor feted him at a goodbye breakfast in June. Colleagues sent the 85-year-old assemblyman off to shouts of “for he’s a jolly good fellow.” They even named a state park after him.

But Mr. Farrell, known to most as Denny, did not retire when all these festivities occurred. He called it quits earlier this month, saying it marked the anniversary of his first government job.

The timing ensured that Mr. Farrell could essentially handpick his Democratic successor, sidelining voters in his Upper Manhattan district after four decades of his incumbency. Stepping down in June would have cleared the way for an open Democratic primary in September. Instead, with the deadline passed for filing election petitions, party insiders gathered this weekend to formalize the choice of Mr. Farrell’s chief of staff.

For decades, seats in the New York State Legislature have traded hands this way in what amounts to one of the last, most powerful vestiges of Tammany Hall-style politics in the state. Election laws here grant politicians and local party bosses and county committees vast sway in picking candidates when legislators leave office in the middle of their term — whether they retire early, pass away, depart for another job or are carted away in handcuffs.