TRENTON, July 8 — When the clock read 12:01 on July 1, Gov. Jon S. Corzine was at his desk at the State House, Assembly Speaker Joseph J. Roberts Jr. was across the street having a drink at the Trenton Marriott, and New Jersey was only hours from the first government shutdown in its history.
For the next six days, and largely out of public view, the state's elected leaders boxed over Mr. Corzine's demand that the sales tax be increased to 7 percent from 6 percent to put the state on sounder financial footing.
One Assembly Democrat from South Jersey tried to remove three North Jersey colleagues from the crucial Budget Committee because they refused to align themselves with Mr. Roberts, who himself is from Camden County in the south. Caucus meetings seemed awkward as some lawmakers clustered in cliques based not on the usual factors of friendship or geography, but by their stand on the budget.
The impasse led to scenes that were bizarre even by Trenton's relaxed standards. Mr. Corzine, a former co-chairman of Goldman Sachs and a multimillionaire, slept in a cot in his office for three straight days, going to Drumthwacket, the governor's mansion in Princeton, to shower.
And for three consecutive mornings, starting on Tuesday, Mr. Corzine demanded that legislators convene at 9 a.m. so that they could listen to him push his budget as fiscally responsible. Senate President Richard J. Codey called it "home room."
"We never thought it through," said Assemblywoman Joan M. Quigley, a Democrat from Hudson County, who was a strong supporter of Mr. Corzine's budget. "No one had Plan B. Nobody had an endgame to this. I would call my husband and say, 'It's like we're still in Iraq, with no way to get out.' "
Not until Thursday afternoon — when Mr. Corzine walked casually past a throng of surprised lobbyists and reporters and into the office of Mr. Roberts — did it become apparent that the impasse over the governor's $31 billion budget would soon be over. Along the way, the brinkmanship idled tens of thousands of workers, cost the state of millions of dollars in revenue and threw New Jersey's traditional political alliances into disarray.
Mr. Roberts had protested the tax increase, saying that he felt that the government could cut enough spending to make up for the $1.1 billion that the increase was projected to generate.
While Mr. Corzine said that he was amenable to a compromise suggested by Mr. Codey to dedicate half of the new revenue to property tax relief, Mr. Roberts did not budge.
At 9:30 on July 1, after the deadline for the budget came and went, Mr. Corzine signed an executive order stating that he had to authorize the orderly shutdown of government because the state had run out of money. The next day, Mr. Corzine met with Mr. Roberts, Mr. Codey and about 20 other legislators and staff members at Drumthwacket.
By then, it had become clear that Mr. Corzine had in Mr. Codey a reliable ally — something that could not have been guaranteed last year, when Mr. Corzine, with tens of millions of dollars of his own money at his disposal, essentially pushed Mr. Codey, then the acting governor, out of the governor's race.
"He and I have become very close," Mr. Codey said in an interview in the Senate at 4 a.m. on Saturday, as the budget bill was being debated.
On Monday, Mr. Roberts issued a belligerent news release, calling for Mr. Corzine to identify the legislators who supported his proposal. A few hours later, Mr. Corzine demanded that the entire Legislature meet at 9 a.m. the next day — known to the rest of the country as the Fourth of July.
His speech on Tuesday lasted 20 minutes, and was greeted by applause two times — when he entered the Assembly chamber, and when he left. The atmosphere was still mutinous, as symbolized by a flier, circulated by the Assembly Democrats, which criticized Mr. Corzine's proposal and asked, "Why are we here?"
Assembly Democrats still felt optimistic that they would prevail. Yet when a group of them, led by Mr. Roberts and Assemblywoman Bonnie Watson Coleman, of Mercer County, met with Mr. Corzine, they encountered a man unwilling to make any concessions.
"The governor seemed to be in a state of denial," said one person who attended the meeting.
In a meeting later of the Assembly Democratic caucus, both Ms. Watson Coleman and Mr. Roberts seemed frustrated by Mr. Corzine's hard-line stance, according to people who heard the speeches.
They said that Mr. Corzine refused to make concessions and did not play politics as usual. And in a dramatic moment, Mr. Roberts asked his members for a show of hands of support for Mr. Corzine's sales tax proposal; only 15 out of 49 did. But that strategy rubbed some members the wrong way; someone grumbled that it seemed uncomfortably reminiscent of "Twelve Angry Men."
One of the most memorable moments came when Mr. Roberts held a news conference in the late afternoon, at which he defiantly declared that the sales tax proposal was "dead."
Mr. Codey wondered at first whether Mr. Corzine would have the stomach to fight on, given the public's distaste for additional taxes and the resoluteness of the Assembly opposition.
"He's become a stronger leader, each day, and he's determined to do what he perceives is the right thing to do," Mr. Codey said. "It was a metamorphosis, right before my eyes."
On Wednesday morning, Mike Donilon, a political consultant who was in charge of Mr. Corzine's campaign commercials in 2000 and 2005, showed up at the State House at 8 a.m., at the behest of the administration.
He was in town to discuss a possible television campaign to push Mr. Corzine's budget, and his mere presence raised the stakes even more.
At an Assembly Democratic caucus meeting later, the discussion "got the most personal and raucous," said one of the members, who did not want to be identified because of the lingering bruises from the debate. There, Assemblyman Herb Conaway, from Burlington, a strong ally of Mr. Roberts, demanded that three of his colleagues on the budget committee — Ms. Quigley, Assemblyman Joseph Cryan of Union County, and Assemblyman William D. Payne of Essex County — be removed because they did not back Mr. Roberts.
"I said, 'Just settle down,' " Mr. Roberts said in an interview. "Let's not talk about this now."
Still, Mr. Roberts and his allies, including Assemblyman Louis D. Greenwald of Camden County, the budget committee chairman, pushed ahead with their own budget, which did not contain a sales tax increase. But with the hearing shown live on television in the small hours of the morning, things got out of hand.
First, the committee, which has eight Democrats and four Republicans, heard testimony from two passionate labor leaders, Robert McDevitt, president of Unite-Here Local 54, which represents casino workers, and Carla Katz, president of Communications Workers of America Local 1034, which represents state employees. Both criticized the alternative budget.
Then, Mr. Cryan, a Democrat who has strongly backed Mr. Corzine, formed a bloc with the Republicans and three other Democrats, thereby signaling that Mr. Greenwald's proposal had no chance.
"After what people saw in that committee, it was obvious that the fight was unsustainable from that point on," said State Sen. Thomas H. Kean Jr., a Republican from Union County.
Many legislators and others viewed that meeting as the turning point. Afterward, Mr. Greenwald and other legislators opposed to Mr. Corzine's plan went to the Marriott for a drink, and looked dejected, according to two people who were there.
While that was going on, Mr. Roberts had in hand a new compromise proposal from Mr. Corzine that would allocate half of the new sales tax revenue to easing the state's property taxes, at least for one year, and perhaps longer. It expanded upon a proposal that Mr. Codey had first made on June 21.
On Thursday, after Mr. Corzine's third speech in as many days, in which he disclosed his latest compromise, things began to change quickly. At some point, Mr. Roberts got on the phone for perhaps 45 minutes with George E. Norcross III, the powerful Democratic leader from Camden County.
"You could see the pressure on him," said one State House official who attended some of the meetings, about Mr. Roberts. "He was really wearing it."
About noon, Mr. Corzine walked though a crowd of lobbyists and reporters to Mr. Roberts's office, in what was interpreted as a sign of deference. At 1:30 p.m. State Senator Bernard F. Kenny Jr., a Hudson County Democrat and a Corzine ally, came out of the governor's office, after a meeting with the three leaders and others.
"The Assembly Democratic caucus broke up," Mr. Kenny declared. "The votes weren't there."
The legislators went to their own caucuses to discuss the deal. And when Mr. Roberts announced the compromise to his members, "there was a standing ovation," he said, and a sense of relief.
At 4:45 p.m. — almost 137 hours after the deadline had passed — Mr. Corzine, Mr. Roberts and Mr. Codey emerged from the governor's office to announce that the end was finally near.