TAUNTON — As residents this year debated a proposal to build a $500 million casino resort at an industrial park here, the future of another massive property six miles north seemed a near certainty: the 154-acre site of Taunton State Hospital, one of the state’s two remaining publicly run hospitals exclusively for the mentally ill, was marked for closure by the governor in January.

The Patrick administration’s closure, planned for the end of the year, would empty 18 historic buildings in this cash-strapped city.

Some 170 patients would be relocated to other hospitals or to supervised community homes, while the hospital’s 410 staffers were assured other state jobs, mostly at a $302 million mental hospitalslated to open in Worcester in a few months.

But a last-ditch effort to save Taunton State Hospital emerged in the Legislature last month, with the Senate voting to keep open 72 beds, roughly 40 percent of the total number, while commissioning a study to assess how many long-term psychiatric beds are needed in the state. The state Department of of Mental Health estimated the cost of keeping the beds open at $6.6 million.

Get The Weekender in your inbox:

The Globe's top picks for what to see and do each weekend, in Boston and beyond.

If the property is shut down, which is likely to be decided within the next two weeks, the state would then form a committee to decide what to do with the buildings and grounds.

The controversy pits those who say the state needs more long-term psychiatric beds, especially in the southeast region, which would be left with none if Taunton State closes, against the Patrick administration and others who say the state will have enough total beds — 626 — through the opening of the new Worcester hospital and the continued use of other beds in other state health facilities.

Senator Marc Pacheco, a Democrat from Taunton who successfully urged his colleagues to approve funds to keep the hospital partly open, said the state needs to study the issue further. “I’m hopeful we’ll have a compromise to keep the lights on,” Pacheco said.

The future of this institution, established in 1854 and once called the State Lunatic Hospital, is expected to be decided by the end of the month as the House and Senate negotiate the final terms of the state’s new budget, which begins July 1. Funds to keep Taunton State open were not in the original House budget proposal.

While the casino plan, preliminarily endorsed in a non-binding refendum by city residents in a vote last week, has been a recent hot topic, the hospital’s closure has been a subject of concern among residents since January, said Karen Coughlin a nurse and and a representative of the hospital’s nurses union.

Two-thirds of the patients come from southeastern Massachusetts, and families want the convenience of visiting them at a nearby facility, she said.

Also, she said, Taunton has grown accustomed to the hospital, helping recovering patients who get privileges to leave the grounds to visit stores and restaurants. Typically, the patients are indigent, suffering from conditions such as schizophrenia, bipolar disorder, and depression.

“It’s not just about jobs, but what’s fair to the patients,” she said.

She also said Taunton was not slated to be closed when the state decided to build the new Worcester hospital. That new facility was expected to accommodate the closing of Westborough State Hospital two years ago, and the shutdown later this year of the Worcester State Hospital.

Marcia Fowler, commissioner of the state Department of Mental Health, insisted that the decision to close Taunton State was not about money. She said her staff determined the state needed 626 long-term beds, and the question was which facilities should be funded to provide for that number.

Ultimately, after much debate, top officials concluded that they could best reach that number through the opening of the new Worcester Recovery Center, with its 320 beds, as well as funding roughly 300 additional long-term psychiatric beds, primarily in Boston and Tewksbury.

“The department is confident, without doubt, that is enough,” said Anna Chinappi, spokeswoman for the department, referring to the 626 beds.

State mental health officials also said its recent decisions are part of a broader national effort to focus on integrating the mentally ill to live and work in society, rather than keeping them in locked, institutional settings. As part of his “Community First” initiative, the Governor Deval Patrick has added an extra $9 million to promote more housing and programs to help patients merge with their communities.

The Patrick administration is eagerly awaiting the unveiling of the Worcester Recovery Center, one of the governor’s signature achievments, which features areas called “downtown” and “neighborhood,” where patients can begin to prepare for life in the community. His plan is for the Worcester hospital to be the only state facility in Massachusetts devoted exclusively to mentally ill patients by next year.

Critics said, however, that without adequate beds, the state will aggravate a crisis that is already straining the state’s medical system, the stranding of severely mentally ill men and women in emergency rooms as they await hospital admissions.

Pacheco said in these cash-strapped times, the state has to be sure that it doesn’t release patients too early, and make sure they get the proper treatment so they don’t end up in prison or rehospitalized.

He insisted that financial factors are the only reason the Patrick administration wants to close Taunton State, and he believes keeping it open is “the investment that will pay off in the future.”

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.