A major task for Minnesota's next governor will be to reset the relationship between the office of chief executive and the Legislature, an often-frayed connection that's been at a low point recently due to bitter sparring between DFL Gov. Mark Dayton and leading Republican lawmakers.

As the session wrapped up in late May, Dayton blasted Republicans as beholden to special interests, unfurling a litany of adjectives that included "vile," "disgusting" and "appalling." Republicans in turn compared the DFL governor to a toddler, calling him vindictive, impulsive and "an embarrassment."

After eight legislative sessions of partisan squabbles, Dayton and GOP lawmakers have come to sound like spouses going through an ugly divorce. And that resemblance has been about more than just mocking, condemnatory language — Dayton and Republican leaders actually wound up in a kind of political divorce court last year after Dayton vetoed the Legislature's budget, with the state Supreme Court ordering them into mediation. It failed.

"It had a pretty bumpy start and a pretty bumpy conclusion and in between there were ups and downs, it's fair to say," said state Senate Minority Leader Tom Bakk, DFL-Cook, when asked about Dayton's relationship with the Legislature. Bakk would know: He found out in 2015 that Dayton was willing to publicly dress down fellow DFLers, too, after the governor used a news conference to accuse Bakk of stabbing him in the back.

As the November election nears and with Dayton not running again, Minnesota voters will again get to choose if they want divided state government, which has accompanied six of Dayton's eight years in office. The five leading candidates for governor — DFLers Erin Murphy, Lori Swanson and Tim Walz, and Republicans Jeff Johnson and Tim Pawlenty — all face the prospect of having to try to strike compromises with the other party at a time when political agreement is out of favor with the bases of both political parties.

Acrimony between the governor and legislative leaders from the other party certainly predated Dayton. Pawlenty, who preceded Dayton as governor, once labeled a Senate DFL proposal to raise taxes "profoundly stupid" — a crack he later said he regretted.

But whoever succeeds Dayton will have to grapple with a partisan chasm. And the breakdown of a working relationship between Dayton and the Legislature, even if it often seemed like so much noise, has not been without consequence: With Dayton and the GOP unable to agree on a tax bill this year, 300,000 Minnesotans can expect a tax increase thanks to lack of alignment between the state tax code and Congress's 2017 federal tax code rewrite.

Even those Minnesotans who don't see taxes go up as a result of dysfunction in St. Paul can expect a bewildering mess when they try to reconcile state and federal obligations in next year's tax filing season.

Dayton — who leaves office at the beginning of next January — writes off the bad feelings as a reflection of the current state of American politics, featuring two sharply divided political parties occupied by people with vastly different worldviews.

"I've had good personal relationships," Dayton said in a recent interview. "But when push comes to shove and there are constituencies and ideologies, a personal relationship is a good start, but it doesn't carry you through to an agreement."

Senate Majority Leader Paul Gazelka, R-Nisswa, said Dayton deserves thanks for his service. But he said the governor struggled to empathize with his opponents.

"I believe he wanted to do what he thought was best for Minnesota," Gazelka said. "Sometimes I think he didn't see that a different group of people might also think they were doing what they thought was best for Minnesota."

House Speaker Kurt Daudt, who has sparred with Dayton since becoming speaker in 2015, took a less charitable view.

"His legacy is a missed opportunity because he could have done good things for the state, but he didn't," said Daudt, R-Crown. "He has failed to work across the aisle."

It wasn't always thus, said Roger Moe, the former longtime DFL Senate majority leader who is now a lobbyist.

"Tragically, the state of civility has spiraled downward," Moe said. "You see it at the national level in politics, and you see it at the state level."

Sen. Richard Cohen, a longtime DFL lawmaker from St. Paul, noted that the Republican Party was being pushed to the right by a wave of Tea Party activism that emerged in 2010 — the year Dayton was first elected governor. Cohen said it brought a new wave of lawmakers who are more fiercely ideological and likely to view compromise as a weakness.

"It's a different kind of Legislature," Cohen said, adding that he feels that dynamic has largely stayed in place since.

Bakk compared the 2011 session, Dayton's first, to a bad play early in a poker game that set the tone for what followed. That year's three-week shutdown, precipitated by a standoff over taxes and spending between Dayton and GOP majorities, ended after Dayton decided he could no longer keep government workers and those reliant on state services in limbo.

After that, Bakk said, Republicans believed they knew how to force Dayton to bend to their will. "They looked at that bigheartedness as a vulnerability and something they could exploit," Bakk said.

Dayton acknowledged how rough it was: "It was a brutal experience for me in my first year as governor." But he said he would make the choice again to keep the mechanics of state government functioning. "I'll take whatever comes with it," he said.

Dayton's supporters point to a long list of accomplishments, although most were packed into a busy two-year period when the DFL controlled the Legislature. That included an income tax increase on the wealthy; an increase in the state minimum wage; legalization of same-sex marriage and medical marijuana; and a restoration of education spending after years of difficult budgets for school districts.

When Republicans controlled one or both branches of the Legislature, Dayton still managed to secure funding for the new Vikings stadium and restoration of the Capitol building; expanded early childhood education programs; instituted new rules to reduce farm pollution; and agreed on billions of dollars in spending on roads, water infrastructure and other public works projects, among other accomplishments.

Dayton said democracy is messy — but still done better in Minnesota than in most places.

"It's contentious and adversarial, and there are real, deeply held differences," Dayton said. "It's not easy, and it's not meant to be easy."