ST. PAUL,�Minn., (CNNMoney) -- Democratic governor Mark Dayton and leaders of the Republican-controlled legislature have reached a deal that will close Minnesota's budget gap and end the state government's shutdown "within days."

"It is my understanding that we have reached an agreement," Dayton said, as the visibly tired legislators emerged from a three hour meeting at the Capitol to speak to press.







"We have a framework agreement, I guess is the best way to look at it," Senate Majority leader Amy Koch said, adding that details will have to ironed out, then drafted, over "the next couple of days."

Minnesota requires that a balanced budget be in place every two years. The state faces a $5 billion budget shortfall, and since a new budget hadn't been agreed to by the start of the new fiscal year -- July 1-- the shutdown began.

Thursday's agreement is based around a proposal Dayton sent to GOP lawmakers that morning in which he stepped away from what had been the cornerstone of his plan -- increased tax revenue.

"I am willing to agree to something I do not agree with in order to spare our citizens and our state from further damage," Dayton wrote.

He said he was willing to go along with provisions put forward by Republicans June 30th -- the eve of what has now become the longest government shutdown in the nation's history.

The plan is now based more on borrowing than on finding new permanent funding sources.

But the governor said Republicans had to agree on a few stipulations of his own: One being a $500 million bonding bill for new building projects. Republicans also also had to agree on killing some of their earlier proposals, including one that would have eliminated 15% of the state workforce.

Republican leaders said for the most part they were now in agreement.

"It is not a perfect scenario, but we are in an imperfect situation here," said House Speaker Kurt Zellers. "There are some things we don't agree with, but it gets the budget balanced and it ends the shutdown."

Once details are finalized the governor will call a special session of the legislature. Dayton said he hoped to be able to do that "as soon as possible."