The balance of power in the Maine Legislature shifted only slightly Tuesday as voters returned a Republican majority to the Maine Senate and likewise sent a slimmer majority of Democrats back to the state’s House of Representatives.

Democrats gained one seat in the upper chamber, but they lost experienced lawmakers as well, as Republican challengers were successful in taking seats two seats from Democratic incumbents in Senate districts 13 and 18. The final tally gives Republicans 18 seats to 17 won by Democrats.

It also appeared that Sen. Mike Thibodeau, R-Winterport, the current state Senate President, would be returning as he defeated Democratic challenger Jonathan Fulford of Monroe, in a rematch.

In the House, Democrats appeared to have won 74 seats to the Republicans’ 73, with results of two races still pending Wednesday morning. Voters also sent two Libertarians to the House. Several races were also close enough that recounts could be expected.

Key victories for Republicans included Senate District 16 in Kennebec County, where challenger state Rep. Henry Beck, a Waterville Democrat who was termed out of the House, was unable to best incumbent Sen. Scott Cyrway, R -Benton. Despite an onslaught of $300,000 in independent spending on Beck’s behalf, Cyrway won with 10,360 votes to 8,789.

Cyrway late Tuesday said he was grateful for the win and aghast at the amount of negative spending that took place during the race. “I just did not believe how much money had been thrown into this race,” Cyrway said. “I hope this shows that negative campaigning does not pay off.”

In northern Maine, Democrats picked up two Senate seats held previously by Republicans, with former state Sen. Troy Jackson, D-Allagash, winning the District 1 seat he previously held by defeating Republican Timothy Guerrette of Caribou.

Jackson, a former state Senate assistant majority leader, gained statewide prominence in his failed bid to be the Democratic candidate for Maine’s 2nd Congressional District in 2014. And the state Senate seat was left open after being vacated by retiring Sen. Peter Edgecomb, a Republican.

In Senate District 2, also in northern Maine, Democrat Michael Carpenter, a former Maine attorney general from Houlton, appeared to defeat Rep. Ricky Long, R-Sherman. Carpenter also ran for the seat in 2014 and narrowly lost to Michael Willette, a Presque Isle Republican, who decided not to seek re-election this year.

In Senate District 3 incumbent state Sen. Rod Whittemore, a Skowhegan Republican, appeared to be fending off Rep. Jeff McCabe, a Democrat also from Skowhegan. McCabe, the outgoing House majority leader, has been at the forefront of dozens of Democratic conflicts with Republican Gov. Paul LePage. But on Tuesday Whittemore prevailed, winning 53 percent of the vote with one precinct outstanding.

In Senate District 18, incumbent Democrat John Patrick of Rumford lost to challenger Lisa Keim. Kiem had 56 percent of the vote with only one precinct outstanding late Wednesday morning.

Both parties also won a seat in unopposed races, with incumbents Nate Libby, a Lewiston Democrat, and Kim Rosen, a Bucksport Republican, set to return. With such an even divide in both chambers, the races for leadership positions will likely be close. Republicans in the House could upend Democrats with help from Libertarians to gain the Speaker’s gavel. In the Senate, Democrats could align themselves with moderate Republicans to install a president more favorable to their side.

State Rep. Ken Fredette, R-Newport, the current House Minority Leader, has called a 2 p.m. press conference at the State House to discuss Tuesday’s results. Senate Republicans will likely make their leadership decisions Thursday, said spokesman Jim Cyr.

While Republicans lost two seats in the Senate, their gains in the House had Maine Republican Party Chairman Rick Bennett claiming victory, especially with the vote in Maine’s more rural and northern 2nd Congressional District going to Republican President-elect Donald Trump. That gave Trump one of Maine’s four Electoral College votes, marking the first split in the state’s Electoral College in modern history.

“The outcome has been overwhelming, and our success is not only unprecedented, but historic,” Bennett said in a prepared statement. ” I am proud to be part of history today. Our victories will change our political landscape for years to come.”