The State Insurance Fund finally did the right thing by settling a long-standing dispute over a 2002 accident in Amherst State Park.

It took a while – five years – and Amherst officials are still puzzling over the sudden capitulation, but they’ll take the win and the $31 million that goes along with it.

Besides divvying up the money among obligations and restocking low balances and perhaps lowering taxes for town residents – and providing for a nest egg against a lawsuit by a wealthy developer – town officials are determined never to find themselves in the same situation. Who could blame them?

Town officials tried unsuccessfully for years to get the State Insurance Fund to reimburse a $23.4 million judgment paid to a Sanborn man, Peter E. Bissell, who suffered crippling injuries when he fell from a ladder while examining the roof of a town-owned building in 2002.

A couple of courts ruled that the State Insurance Fund had to repay the money, but the agency refused. The reason for the refusal seemed to be simply that no one could make it pay, at least as far as lawyers representing the town could tell.

Meanwhile, the town had paid $23.4 million to Bissell, because the town was maintaining the property, and then plunged into a years-long battle with the State Insurance Fund. Bissell was awarded $30.3 million in State Supreme Court in 2007, an amount later reduced to $18.3 million. The town paid $23.4 million because of interest.

The town’s insurance carrier covered $10 million of the judgment and the town borrowed $13.4 million to pay the remaining amount. In 2011, the town began repaying that debt by borrowing $3.2 million a year from its own reserves. With a dangerously low fund balance and auditors cautioning that the town’s financial record would have otherwise been unblemished, officials continued working on how to get justice for taxpayers.

One can only imagine the gnashing produced during the recent seven-hour meeting in a downtown office building. But somehow the town prevailed and with no thanks to the intractability of the State Insurance Fund and the state Scaffold Law that is a detriment to New York.

The law prohibits contractors from mounting a defense when a worker is injured in a fall. Defenders have vigorously argued that it is a protection for workers, but that is far from the case.

New York is the only state with such a law remaining on the books and its safety record is comparable to that of similar states. Injured workers would still have full access to the courts without this law, which only serves to send insurance rates through the proverbial roof and, as a result, construction costs with it.

That is not to say that injured workers like Bissell don’t deserve the judgments they receive. But the system for reaching them needs to be reformed.

Amherst Supervisor Barry A. Weinstein had the right idea when he said, “We are much more careful allowing workers on our property without insurance. We’ve been obnoxious. …”

Such a tragic accident was only made worse by this long and unnecessary fight.