Minnesota lawmakers crossed the finish line of their session early Friday after reaching a delicate compromise over the state's two-year, $46 billion budget.

Just before 3 a.m. on the special legislative session's fourth day, the Senate approved the bonding bill on a 60-2 vote. About a half-hour earlier, the House did the same on a 119-11 vote. Adjournment votes followed, and the bills were headed to Gov. Mark Dayton

Before that, legislators approved a $650 million tax cut, $483 million in new money for schools and a $300 million transportation bill that Dayton has agreed to sign, and a ban on city-mandated wage and sick leave laws that the DFL governor promised to veto.

The week was filled with late nights, uncertainty and hours of waiting for something to happen while GOP leadership and Dayton and his staff engaged in closed-door negotiations.

Labor unions and other progressive interest groups marched and chanted at the Capitol Thursday, seeking to buck up Dayton, who is in his second and final term.

With both the House and Senate in a recess for yet more closed-door negotiating, bleary-eyed lawmakers and lobbyists gathered in the Capitol rotunda to hear some late night bagpipe playing by Rep. Bob Loonan, R-Shakopee.

But as the clock passed midnight, there was still work to be done: most notably a health and human services measure that ran 672 pages and totaled more than $15 billion. That bill had significantly smaller cuts in assistance programs than originally sought by Republicans, and also dropped a GOP provision to eliminate the state's health insurance exchange, MNsure.

Still, Sen. Tony Lourey, DFL-Kerrick, argued against the bill, saying accounting gimmicks would rob the state of its ability to care for needy Minnesotans in the future.

The bill passed the Senate at 1:30 a.m. after Dayton intervened to help ensure its passage, senators said. It passed the House after 2 a.m.

Before the House and Senate passed a nearly $1 billion package of public works projects financed with borrowed money, it was almost derailed by a dispute over a single park trail.

Because the public works package leveraged the state's borrowing authority, it required a so-called supermajority to pass, meaning Republicans would need at least six DFL votes in the Senate.

The Republicans' one vote Senate majority was further imperiled by the absence of Sen. David Osmek, R-Mound, who was on work trip for his job outside the Legislature.

The DFL used their leverage to secure a victory for public employee unions, a key political ally. In a bill funding a number of state agencies, Republicans agreed to remove language the unions didn't like that would have made it harder to ratify state worker contracts.

The tax bill lawmakers completed on Thursday divides $650 million in tax breaks among Social Security recipients, Minnesotans with student loans, parents with child care costs, business property owners, farmers and smokers. The bill will also allow Twin Cities bars to stay open until 4 a.m. during the 2018 Super Bowl.

The transportation bill has $300 million in new money from the state to build and maintain the nation's fifth-largest road system. Dayton successfully prevented broad cuts to Metro Transit.

The public school budget bill would increase per-student payments to districts by 2 percent in each of the next two years, for a total of $483 million in new money over and above enrollment increases and inflation, including $50 million to expand a prekindergarten program.

Although the budget bills, which fund state government for two years, passed after hours of negotiations with Dayton and his staff, the governor still has to sign them before they become law. The potential for Dayton vetoes served to enforce the tentative agreements.

Before the special session, lawmakers had approved spending measures covering public safety and the courts, higher education, the environment and natural resources, agriculture, and jobs and economic development. The budget bills together constitute an overall state spending deal struck between Dayton and GOP legislative leaders, but settling hundreds of little deals through the bills — under growing political pressure — has contributed to the slow pace at the Capitol.

In giving final approval to the bill to stop cities from passing their own workplace rules, Republicans who control the House and Senate achieved perhaps their chief policy goal of the session — but did so knowing Dayton would veto it. The measure, known around the Capitol as "pre-emption," provoked an intense debate between local leaders and their allies in cities like Minneapolis and St. Paul, which have both implemented employer sick-leave policies; the Minneapolis City Council is also moving toward a $15 city minimum wage.

Republicans responded to Dayton's veto threat by incorporating into the measure several other items he supports, including an extended family leave program for state workers who become new parents. Dayton called that linkage "unconscionable" but has said he will still veto the bill, which would have the result of terminating a six-week paid leave program in place since last November.

After days of exhaustion and raw emotion, the Senate experienced a few moments of levity Thursday: Sen. Karin Housley, R-St. Mary's Point, asked the Senate to don T-shirts of the Nashville Predators NHL team, for whom her husband Phil is assistant coach, and head to the front steps of the Capitol, where they were photographed to wish the team good fortune.

erin.golden@startribune.com 612-673-4790

patrick.coolican@startribune.com 612-673-4789