After four years of court battles and lobbying in New Hampshire, Nixon Peabody lawyers are set to reap more than $20 million in contingency fees for their role helping medical malpractice policyholders in the state secure $110 million in excess premiums paid to a quasi- governmental insurance fund.

In litigation that involved eight discrete actions in various legal and administrative venues, the firm’s lawyers succeeded in blocking New Hampshire lawmakers from transferring the excess payments to the state’s coffers and in winning the funds back for policyholders.

Last month, Merrimack County Superior Court Justice Richard McNamara signed off on a plan to allocate an initial $85 million to a class of about 6,000 healthcare providers. An additional $25 million is being held back to cover potential tax liabilities. On Tuesday, lawyers at Nixon Peabody learned that there were no objections to the judge’s ruling, meaning the distribution of funds will move forward.

“We had no idea when we set out that this odyssey would take four years,” said Nixon Peabody’s W. Scott O’Connell, who led the effort with partners Kevin Fitzgerald and Gordon MacDonald. As of July, Nixon Peabody had invested more than $4.6 million in firm time to the matters, according to the firm’s accounting.

“We look like geniuses today, but the story would be quite different if it ended differently,” Fitzgerald said Tuesday.