The end to Minnesota’s historic state government shutdown is in sight.

Gov. Mark Dayton and Republican legislative leaders agreed Thursday to a budget deal that should reopen government doors and put 22,000 laid-off state workers back on the job within days.

“We have an agreement,” albeit a tentative one, Dayton said shortly after 5 p.m., when he and Republican leaders House Speaker Kurt Zellers and Senate Majority Leader Amy Koch emerged from a three-hour negotiating session in his Capitol office.

Koch said the three leaders still must work out the details of a $35.8 billion budget package before Dayton calls the Legislature back into special session to pass it.

The Democratic-Farmer-Labor governor said he plans to do that “very soon, within days.” He said he, Koch and Zellers “expect to be here all weekend” wrapping up the deal.

Lawmakers were told to prepare to return to St. Paul as early as Monday or Tuesday.

“We want to get the lights back on and Minnesota back to work as soon as possible,” Dayton said.

This is Day 15 of the shutdown. When lawmakers pass and he signs the remaining nine budget bills, it will end the longest and most extensive shutdown in state history.

Dayton dropped a political bombshell Thursday morning by announcing he would abandon his demand for a $1.4 billion tax increase to balance the state budget. Instead, he said he would accept an offer GOP leaders made June 30 to provide new revenue by delaying $700 million in state payments to schools and borrowing $700 million to be repaid by future tobacco company payments to the state.

The deal gives Dayton the money he wants to prevent “draconian cuts” in state programs and services, while it enables Republicans to keep their promises not to increase taxes.

“Despite my serious reservations about your plan, I have concluded that continuing the state government shutdown would be even more destructive for too many Minnesotans,” Dayton said in a letter to Koch and Zellers.

“Therefore, I am willing to agree to something I do not agree with – your proposal – in order to spare our citizens and our state from further damage.”

Although Republicans aren’t happy with the deal, Zellers, R-Maple Grove, said it would erase a projected $5 billion budget deficit and put the state back to work.

“We’re spending more than we wanted to, but at the end of the day, we had to compromise,” he said.

He and Koch, R-Buffalo, predicted they would have enough Republican votes to pass the budget.

The deal balances the budget without new gambling revenue, shooting down proposals for slot machines at racetracks or a downtown Minneapolis casino.

A proposed $1.1 billion Minnesota Vikings football stadium isn’t part of the deal, either.

But Lester Bagley, the Vikings’ vice president for public relations and stadium development, said the team has nearly reached an accord with Dayton and key lawmakers for how to pay for the facility.

He said he’s hopeful the stadium can take the spotlight in a special legislative session as soon as a budget is approved.

Dayton tacked three conditions onto his offer:

– He insisted that Republicans drop all the policy changes they proposed to make in the budget bills. Those proposals included banning human cloning and taxpayer funding of abortions; requiring voters to show photo IDs at the polls; and repealing Minnesota’s participation in the federal Patient Protection and Affordable Care Act, dubbed “Obamacare” by Republicans.

– He demanded that Republicans abandon their call for a 15 percent reduction in the state workforce over the next three years. Dayton said in a Pioneer Press interview Thursday that he expects to cut the number of state employees by 6 percent over the next two years.

– He asked Republicans to pass a $500 million bonding bill to put laid-off construction crews back to work on public projects. The GOP leaders agreed to try, but Dayton said a bonding bill is “not a requirement for proceeding” with the rest of the budget.

Under the Republican offer, Dayton said, school districts would get an additional $50 per pupil in state aid in each of the next two years to offset their costs of borrowing money to fill the gap until their delayed state payments arrive.

In addition, he said, the University of Minnesota’s appropriations would be cut $10 million less than the Legislature previously approved.

Borrowing money to bail the state out of a budget crisis is a bad deal, Dayton acknowledged, but “this is the only viable option that’s potentially available.”

Republicans had refused to spend more than the $34.4 billion that state finance officials forecast the state would collect over the next two years under current law, and they rejected any tax increases. Dayton had been insisting on increasing income taxes on the wealthiest 1 percent or 2 percent of Minnesotans to prevent what he considered unacceptable service cuts.

According to a Dayton staff summary, borrowing additional revenue would:

– Prevent nearly 140,000 Minnesotans from losing their state-subsidized health insurance.

– Avert hefty property tax increases.

– Preserve most bus transit services.

– Hold down college tuition increases.

– Maintain services for seniors and those with disabilities and mental illness.

But no one liked the deal.

Former Republican Gov. Arne Carlson, who convened a panel this month that recommended a mix of tax increases and spending cuts to solve the state’s budget crisis, said he was “dumbfounded” by Dayton’s offer.

State officials should balance a budget with permanent fixes, Carlson told Minnesota Public Radio. “Borrowing should be off the table,” he said.

He called Thursday’s offer “the worst proposal that has been discussed in the last six months.”

“It not only delays the problem, it makes it worse,” Carlson said. “We cannot borrow our way to success. We can only borrow our way to failure.”

Dayton unveiled his offer during a speech Thursday morning at the University of Minnesota’s Humphrey School of Public Affairs. Afterward, he told reporters that Republicans would be responsible for running up debt to resolve the budget crisis.

“I’ll own the budget, but they’re going to have to own the financing of it,” he said.

In an interview, he acknowledged that borrowing money would increase a projected budget deficit for the next two-year budget.

The deal is only a temporary fix, Dayton said, but it would give him and his Cabinet – which has been preoccupied by the budget crisis for their first six months in office – time to devise reforms in the next year or two that provide “several hundreds of millions of dollars of savings and efficiencies.”

“Making government more efficient and cost-effective is going to be crucial,” he said.

Recognizing that Republicans would not agree to increase taxes, he said he had been considering accepting their final offer for several days.

During the previous two days, he had appeared at public forums on the budget in St. Cloud, Rochester and Albert Lea. He said the people who spoke out at those events reinforced his decision to end the shutdown quickly.

“I heard a very strong chorus of ‘We want to get this done now,’Ã¢ ” he said.

Some people thought the shutdown would “show everybody that state government is irrelevant,” he said. “I think the opposite. It’s shown how pervasive state government is in our lives.”

For instance, he joked, you can’t even get a beer without state approval. (Some beer makers haven’t been able to renew their brand-label registrations during the shutdown and were told to stop selling their products in the state.)

DFL legislative leaders praised Dayton for negotiating an end to the shutdown.

House Minority Leader Paul Thissen, DFL-Minneapolis, called Dayton’s offer “an act of true statesmanship.” But Thissen quickly noted it “is by no means the best or even second-best budget for our state.”

However, other DFLers trashed the deal.

“I will not be putting MN’s budget on a credit card,” Rep. Carly Melin, DFL-Hibbing, wrote on Twitter. “When I ran on fiscal responsibility, I meant it.”

Members of the House and Senate Republican majorities, however, will decide the fate of the agreement. GOP lawmakers who reacted to Dayton’s offer on Minnesota Public Radio were cautiously optimistic.

“I am certainly elated to hear there is some movement…but the devil is in the details,” said Sen. John Howe, R-Red Wing. “But I’m certainly hopeful.”

Rep. John Kriesel, R-Cottage Grove, said, “I’m hopeful also this is the end.”

Doug Belden, Dennis Lien and Dave Orrick contributed to this report.