An expensive and hotly contested battle for control of the Minnesota Legislature came to a head Tuesday, with the outcome of a handful of legislative races expected to shape state politics for the next decade.

The final split in both chambers remained in flux late Tuesday, with a number of competitive races across the state too close to call hours after polls closed.

While all 201 state legislative seats were on the ballot this year, the fight was focused on fewer than a dozen competitive seats likely to determine majority control in the state Senate, where Republicans hold a narrow 35-32 advantage. Democrats were defending a 16-seat edge in the state House.

Results in those closely watched races trickled in Tuesday. But with many seats in play on both sides and ballots still being counted, legislative leaders braced for a late night.

"We're telling people to be patient, to just wait and see how the system plays out," state Sen. Melisa Lopez Franzen, DFL-Edina, told reporters Tuesday.

The results in a handful of those competitive races, some of which could come down to hundreds of votes, will determine whether state government remains politically divided as it is now or fully controlled by Democrats.

The outcome will likely have significant implications for state policy, as DFL Gov. Tim Walz and the Legislature prepare to tackle a budget deficit, the pandemic and the redrawing of the state's political maps. The fate of issues such as marijuana legalization, school funding and tax policy hang in the balance.

Given the stakes, campaigns, political parties and outside groups have dedicated tens of millions of dollars in campaign cash to state races. The spending is on track to exceed the $30 million spent in 2016, the last time the entire Legislature was on the ballot. The latest campaign finance reports, filed in late October, showed DFL-aligned groups outspending GOP rivals by significant margins.

Democrats' hopes for winning a majority in the Senate were pinned on securing a net gain of two seats or more. Some of the most heated races played out across the suburbs, where polling and 2018 state House races have showed President Donald Trump and other Republicans losing ground.

Democrat Ann Johnson Stewart defeated Republican Greg Pulles to pick up one such seat in the western suburbs. Stewart carried the district, which was left open by the retirement of GOP Sen. Paul Anderson, by about 18 points.

In another hard-fought suburban seat, Sen. Warren Limmer, R-Maple Grove, led Democrat Bonnie Westlin by about 1,000 votes late Tuesday night.

Senate Republicans were on offense, too. DFL Sen. Matt Little of Lakeville trailed challenger Zach Duckworth by a double-digit margin with about 80% of precincts reporting Tuesday night, although many ballots were still being counted.

In southern Minnesota, Republicans also posted an early lead over DFL Sen. Dan Sparks of Austin.

Wins by Republicans in those districts would mean Democrats would need to flip even more seats to secure a majority.

In the House, Republicans would need to win nine seats to overcome the DFL's margin. Republicans had targeted DFL incumbents running in districts Trump won in 2016 as they tried to recapture some suburban swing seats the DFL picked up in the 2018 midterms.

One of those suburban freshmen, DFL Rep. Kelly Morrison of Deephaven, appeared poised to hold off a challenge from Republican Andrew Myers on Tuesday. With 100% of precincts reporting, Morrison led by about 300 votes.

The caucus also hoped to see gains in greater Minnesota by unseating rural Democrats.

Republican challengers posted early leads in at least two of those seats Tuesday night, according to initial returns. But the contests remained too close to call as of 10:30 p.m.

House Democrats hoped to expand their majority, or stem other losses, with challenges against Republican legislators running in districts trending the DFL's way. Several of those GOP incumbents appeared poised for victory Tuesday.

While the outcome of the legislative contests will shape Minnesota state policy, campaigns largely focused on messages trumpeted by the top of the ticket.

Republicans echoed Trump on law and order while Democrats emphasized health care and the need to control the coronavirus pandemic.

The top of the ticket was expected to affect the contests in other ways, too.

Senate Majority Leader Paul Gazelka, R-East Gull Lake, said a close race between Trump and Democratic nominee Joe Biden would increase the odds of holding a Senate majority. A big win by Biden, however, is favorable for a DFL takeover. Biden was declared the winner in Minnesota, with 53% of the vote to Trump's 45% late Tuesday.

Staff writer Jessie Van Berkel contributed to this report.