BOOTHBAY HARBOR, Maine — A state agency has determined that Lincoln County Healthcare must once again provide urgent care 24-hours-a-day, 7 days a week in the Boothbay area.

In a letter Tuesday, Maine Health and Human Services Commissioner Mary Mayhew authorized the merger of Miles Memorial Hospital in Damariscotta and St. Andrews Hospital in Boothbay Harbor only if certain conditions — including the presence of a round-the-clock urgent care center in the Boothbay area — are met.

Within three months, the center must return to its original hours, 24 hours a day, seven days a week, for at least three years unless Lincoln County Healthcare can demonstrate that it has not been used enough to offset costs.

“I have determined that the ordinary economic development of health care for the Boothbay region would be adversely affected … if the applicant who provided acute emergency care was not required to maintain an appropriate urgent care presence,” Mayhew wrote.

Citing low patient counts and other financial concerns, Lincoln County Healthcare closed the hospital’s emergency room — the only one on the Boothbay peninsula — in October 2013. The hospital became an urgent care center, without an emergency room, inpatient services or the ability to accommodate critical care patients.

But residents opposed to the closure organized a task force and spoke out against the action.

Task force member Margaret Perritt said prior to the closure that Miles is too far away for a critically ill patient who lives, in the worst case scenario, on the tip of Southport island. An ambulance leaving Boothbay must pass St. Andrews, travel approximately 10 miles to the patient, then pass St. Andrews again and travel another 18 miles to Miles, she said.

On Thursday, Perritt said the task force members are “ecstatic” about the commissioner’s decision.

Hospital officials were “surprised” by the condition that Lincoln County Healthcare provide round-the-clock urgent care, spokesman Scott T. Shott wrote in an email Thursday.

The company is “working diligently to evaluate the intent of the conditional approval and … weighing our options as we fulfill our mission to ensure access to high quality, patient-centered and affordable health care,” he wrote.