ALBANY – In a first-floor conference room of the Millennium Hotel in Cheektowaga in early October, senior state and Erie County officials sat on one side of a U-shaped table. Representatives from the Buffalo Bills sat across from them.

The gathering was so sensitive that the PowerPoint presentations being shown on a screen had to be shut off several times when hotel staff suddenly entered to replenish the coffee and Danish and sandwiches.

The room was even booked under a fake name so no one could figure out it was related to the Bills.

“It felt like the Paris peace talks. … It was what diplomats call a fair and frank and full exchange of views. It was cordial, but pointed on both sides,” said a senior official familiar with the negotiations that took place over the recent months between the representatives of Gov. Andrew M. Cuomo, County Executive Mark C. Poloncarz and the Bills.

The sides were far apart over a key component of any deal for government funding to renovate Ralph Wilson Stadium: how much the team’s current or future owners will have to pay as a penalty if the team wants to pull out of Buffalo.

At that meeting, the Bills were tossing out numbers like $30 million. The demand from the Cuomo administration: $400 million, more than what the team has gotten in public subsidies over the past 12 years, as well as the new contract deal to renovate the stadium that was announced Friday.

“It took them by surprise. But ultimately, they came around to it. We wanted a genuine penalty to make if financially impossible to breach the lease. That’s the intent of it,” said an official with knowledge of the talks who spoke on condition of anonymity.

“We had one thing very important to us. While we were willing to provide funding for stadium improvements, there was no way without an ironclad guarantee the Bills would stay even with a change of ownership,” the official said.

At the time, the sides were not sure a deal could happen. The Bills were talking about a short-term lease. The county was talking about up to 20 years. And neither the county nor the state had interest in one idea floated by the Bills for a one-year, temporary arrangement to punt the issue over until next year.

At about the same time, Cuomo started to get personally involved in the discussions that eventually would have the state kicking in the most money to keep the team from leaving. Cuomo reached out and had multiple conversations with NFL Commissioner Roger Goodell and Bills Chief Financial Officer Jeffrey Littmann.

“Generally, the league doesn’t get involved in these talks, but the governor thought it was helpful. Goodell is a native Western New Yorker, and the governor appealed to his hometown sense. They developed a very good rapport,” the official said of Cuomo and Goodell, who grew up in Jamestown and had already expressed a desire to see the Bills stay put.

Indeed, Goodell was involved right up until Thursday evening, when the deal finally came together. The sides thought they were all set, when the NFL’s top lawyer raised a legal concern about the relocation penalty – a key component of the lease.

“What is great about the NFL and the relationship with Cuomo and Goodell is that in two hours the league turned it around and came up with different ideas for the language of the contract,” the source said.

Besides the crucial Oct. 2 meeting in Cheektowaga, negotiators pointed to another key session.

On Oct. 12, Cuomo had already offered, in a Buffalo News article, to meet personally with team owner Ralph Wilson if that would help move the pace of the talks. But on that mid-October day, Lt. Gov. Robert Duffy, a lifelong Bills fan and former mayor of Rochester, along with Howard Glaser, the detail-oriented negotiator and one of Cuomo’s most trusted aides, flew on a commercial jet to Detroit for a secret meeting at Wilson’s headquarters in Gross Pointe.

A small group attended: just Littmann and Mary Owen, the niece of Wilson’s wife, a trusted adviser to the Bills owner. Representing Poloncarz was his key adviser, Richard Tobe, who has been a longtime government facilitator of big deals.

The meeting was to last a couple hours; instead, the talks stretched on for more than six hours. They went so late, in fact, that a Michigan state trooper helped rush Duffy and Glaser to the airport and whisk them through security so they could keep negotiating longer without missing the last flight back to New York that night.

“We made a lot of progress, including the conceptual notion of a significant penalty of relocation,” said one official.

“From that point forward, we sort of had an idea of the basic terms, but we were not there yet,” said Poloncarz, who counted 50 different phone and face-to-face meetings – not including the final frenzy of sessions this week – since talks began to heat up during the summer.

Following the meeting in Detroit, lawyers took over the work of turning the conceptual deal into working contract provisions. Sources say a deal was extremely close when Superstorm Sandy hit, and Cuomo, Glaser and Duffy had to dedicate most of their time to the downstate devastation.

Cuomo and Poloncarz believe the $400 million relocation penalty will make it hard for the team to break the lease if Wilson, who has been committed to keeping the team in Buffalo, dies and a new ownership group emerges. As Poloncarz put it: The team is valued at $800 million, and Friday’s deal adds another $400 million in costs if a future group were to buy the team and try to move it.

Government officials say the new deal is better than the 1998 arrangement to keep the team in Buffalo because the Bills will be paying $35.5 million of the stadium renovation costs.

The county will pay $40.6 million, and the state’s share will be $53.8 million. Moreover, the terms contained in the 1998 agreement that provides government funding to the team for operating costs – about $11 million a year, according to the state – will continue in the next contract.

In all, when all the pots are added up, the total deal is $271.52 million, Poloncarz said. Of that total, the Bills will pay $44.6 million (16.5 percent), the state will pay $123.5 million (45.5 percent), and the county will pay $103.3 million (38 percent).

While the county will have to borrow more than under the 1998 deal to pay for its share of the capital renovations, Poloncarz said, it will be easier for the county each year because it will not have to directly pay cash for the operating portion of the agreement. How much the new bonding will end up costing taxpayers is uncertain.

One official said the total public investment of $226 million between the county and state compares to about $214 million in the 1998 deal. But that older deal only called for about $68 million in stadium investments, with none of the money coming from the team.

“In that 1998 deal, the entire brunt of the capital portion was on the state. Now, all parties have a stake in this,” the official said.

While talks had their tense moments, the official said it became clear to Cuomo and his advisers that Wilson and his executive team were working for the long term. “They really do have a commitment and love for Western New York,” the official said of the Bills executives.

For his part, Cuomo said he is “proud” to have the state pay the lion’s share of the financial package to have the team stay in Buffalo. “It is a fair agreement to all parties. I don’t think every party got everything they all wanted, but that normally is the essence of a fair trade,” the governor said.