City Hall is finally fixing a dysfunctional contracting system that left the nonprofits that provide housing, counseling and aid for New York’s neediest in dire financial straits — waiting months or more for payment — thanks in part to a string of stories in The Post.

As of July 1, the embattled Department of Homeless Services managed to get 90% of its contracts under the city’s new budget either paid or set to be paid, a significant improvement over the past, nonprofits told the paper.

“Timely registration means that nonprofits have the ability to access funding to deliver the critical services on which New Yorkers rely,” said Catherine Trapani, the executive director of Homeless Services United, an umbrella organization for groups that provide aid New Yorkers living in shelters. “We are grateful to our partners in government for working with us to achieve this milestone.”

“We are also grateful to The Post for keeping up the pressure to make sure we got it done,” she added.

The new reforms follow yet another year where the city’s social services agencies struggled to pay their bills on time, a Post analysis found.

The Department of Social Services was late 95% of the time paying for new contracts, while the city Health and Hospitals Corp. was also late 95% of the time, the $2.1 billion-a-year Department of Homeless Services was late 92% of the time, and the $419 million Department for the Aging was late 90% of the time.

The paper examined new contracts awarded during the city’s most recently completed budget, which ran through June 30.

Nonprofit sources said the improvements could be traced back to a streamlining of some of the contracting paperwork and agencies being ordered to move more quickly.

For instance, Homeless Services would often wait until June to begin renewing ongoing contracts, making it nearly impossible for new agreements to get sent to the Comptroller’s Office for payment on time. This year, the agency began working on renewals in March.

One veteran homeless services provider praised the changes but blasted City Hall for taking more than five years to tackle the problem.

“We’re optimistic about these changes, but it’s been a long time coming,” the person said. “The delays have cost nonprofits a lot of money and it’s a shame that it’s taken this long for the administration to take this issue seriously.”

The Post first highlighted the habitual tardiness of the city’s social service agencies in a May 2018 front-page story that exposed that DHS was late paying nearly 80% of contracts since 2013.

The constant delays slowed New York City’s $2 billion-a-year effort to combat homelessness and left providers in financial straits — and even forced one to temporarily cut off health care for its employees, sources told The Post. Other nonprofits got so sick of the city’s tardiness they refused to bid for contracts.

City Council members and Mayor Bill de Blasio promised reforms, which were slow in coming.

“We’ve made important progress working through several years of backlogged contracts that we inherited,” said DHS spokesman Isaac McGinn. “We’re making good on our commitments to right-size this work stream once and for all.”