A Portland attorney has stepped forward to save Sweestser’s Learning and Recovery Center in Brunswick from potentially closing on June 30.

The center, for people with mental illness and developmental disorders, was in danger of closing because Sweetser and the Maine Department of Health and Human Services couldn’t resolve a dispute over $50,000.

Sweetser asked the state to contribute more money toward the center’s annual budget of nearly $300,000. That would bring Sweetser’s portion of the operating costs down from about $90,000 per year to $40,000, in line with what it contributed to operations when the center opened 10 years ago.

Instead, the DHHS kept funding level.

The issue came to a head last week when Sweetser announced that the center would likely close on June 30 without additional state funding.

Daniel Lilley, who is well known as a criminal defense attorney, now says he will donate $50,000 to support the center, which would save the center from closing for at least one year. In an emailed statement, Lilley said thousands of people depend on the center’s services.

“We are assured that with this gift, this facility will remain open for another year and provide the peer support service to those people with health issues that have stalled their lives,” he said. “The services that include an alternative to formal hospitalization will now not be closed for lack of money.”

Lilley and his wife are making the donation in memory of their late son, David A. Lilley.

Sweetser, a Saco-based nonprofit with a $50 million annual budget, was trying to raise funds to save the center.

Cindy Fagan, a Sweetser vice president, said in a prepared statement, “We could not have been more pleasantly surprised to receive the call from Mr. Lilley, as his incredible gesture now puts us in a better position to continue working with the state and most importantly to better serve our clients.”