As of Thursday morning last week, financial projections for the Steamship Authority included a $22 million operating deficit by the end of the year and a potential tax assessment for the six Island towns totaling upwards of $7 million.

That was the best-case scenario.

Then on Thursday evening, the surprise passage of a last-minute bill sponsored by state Sen. Julian Cyr had the potential to erase one of the problems by relieving the port communities from a tax liability in the event there is a pandemic-related SSA budget shortfall this year.

An amendment to the state supplemental budget, the bill still needs to clear the house and the governor’s desk to become law.

But the amendment was far from preordained and involved months of back and forth behind the scenes at both the state and local level, including navigating mixed signals from the governor and an array of tricky politics.

In interviews with the Gazette, Senator Cyr and SSA general manager Robert Davis described the challenging process that took place over the past three months to hedge against a teetering financial ship.

“This was not an easy thing to get done,” Senator Cyr said. “It’s not smoke-filled rooms. It’s really more like a conversation with a really smart 20-something analyst.”

Although there is no guarantee that the amendment will be reconciled in the house and be signed by the governor, Mr. Cyr and Mr. Davis are optimistic.

“This is the first of many steps,” said SSA general manager Bob Davis.

The first step was nearly three months ago.

On April 17, with the boat line facing the prospect of financial ruin after traffic had crashed during the pandemic and there was no clear end in sight, Mr. Davis fired off an urgent letter to Gov. Charlie Baker requesting immediate assistance to keep the state-chartered ferry line afloat.

The SSA is the only transportation authority in the country that operates without state and federal subsidy, relying solely on fares for its operating monies. The boat line has not run a deficit in more than 50 years.

Mr. Davis said after he sent his letter, conversations began immediately with Senator Cyr, Rep. Dylan Fernandes and the state Executive Office of Administration and Finance, a branch of the Baker administration dedicated to public policy.

The initial answer was no.

“The Steamship Authority is basically not an entity that we have jurisdiction over, for all intents and purposes,” the governor said during one of his daily press briefings, 10 days after the letter was sent. “I believe most of their rule-making and regulatory oversight is federal,” the governor added.

The reaction confused and surprised Mr. Davis and state legislators.

“Not to speak for the governor, but it may have been more along the lines of — we’re regulated by the Coast Guard, so that’s perhaps what the federal piece of it was,” Mr. Davis said.

A short time later the SSA did receive a $12 million cash influx from the CARES Act, a federal stimulus program, giving it an operating cushion for the summer. But as the pandemic dragged on and ferries ran mostly empty, the prospect of a substantial deficit still loomed. At one point Mr. Davis estimated the shortfall could reach $50 million.

Senator Cyr and Representative Fernandes brokered further conversations with EOAF. But there was reluctance on Beacon Hill, especially after the influx of CARES Act money.

“More of the pushback at the state level was, well, since they got some federal help, maybe they’ll get some more federal help,” Mr. Cyr said.

One idea called for creating a $50 million trust fund that the SSA could use to cover shortfalls.

“We looked at a number of different scenarios,” Senator Cyr said. “One was a limited fund to be maintained by the treasurer’s office that they [the SSA] could sort of draw upon. Basically a pot of money that you could put these short-term pandemic dollars in.”

But there was no clear funding source and the idea never got traction, he said.

With that idea on hold, Senator Cyr said it had become clear through conversations with EOAF that the Baker administration would likely not seek to hold the port towns responsible for any deficit, as spelled out in the boat line’s 1960 enabling legislation.

But there was no guarantee.

“It was an agreement [that the towns would not be on the hook for the payments],” Senator Cyr said. “There was nothing in writing there, and the municipalities were still at significant risk.”

Then when supplemental budget proceedings began, Mr. Cyr saw an opportunity to codify an amendment that said the towns would not be liable for any SSA budget shortfall. It changed the narrative from a bailout to a one-time legislative fix, he said. Plus all monies in the supplemental budget — about $1.1 billion — are required to be federally reimbursed, marking a potential benefit for the state as well.

“It was the senator’s idea,” Mr. Davis said, speaking of Mr. Cyr. “He had seen that there was some consideration being made for the state to request funds from the Federal Reserve Municipal Liquidity program. That was the program back in April, when we were burning through cash, that we thought the state could procure funds for us.”

After debate on Beacon Hill last week, including spirited remarks on the senate floor from Senator Cyr Thursday, the amendment passed unanimously.

“People realized this was a different proposal,” Senator Cyr told the Gazette. “Not to give them [the SSA] a bailout, but to hold the port communities harmless.”

Town administrators in Tisbury and Oak Bluffs, the two port towns on the Vineyard, were among those who lauded the move.

Senator Cyr made it clear that the amendment has not yet reached the finish line. He said reconciliation with the house budget appears likely, but it remains unknown how it will be received by Governor Baker.

“If it doesn’t get in, my hunch would be it’s the administration that for some reason has a significant objection to this,” Senator Cyr said. “Basically what it does is it memorializes what we were planning to do anyway for the Steamship Authority . . . which is crucial.”

Mr. Davis said if the amendment wins final approval, it doesn’t mean a blank check for the boat line. He noted among other things that the SSA has debt obligations, including a detailed schedule of upcoming bond interest and principal payments.

“We have a responsibility to the communities and the commonwealth to make sure we run as efficiently as possible,” Mr. Davis said. “This wouldn’t be a blank check type of thing.”

Senator Cyr said he was gratified at the opportunity to help.

“It feels pretty good when you can successfully go to bat for your communities, particularly communities who can be sort of left out,” he said.