HARRISBURG, Pa. (AP) — Democrats won control of the Pennsylvania House in special elections Tuesday, wresting partial power from Republicans for the first time in a dozen years in the closely competitive swing state.

Democrats won all three vacant Pittsburgh-area House seats to claim a slim edge over Republicans, finally securing a majority they first appeared to have won in last November’s General Election. Republicans still hold the Senate, creating a political division that could make it difficult for lawmakers to send priority bills to new Democratic Gov. Josh Shapiro.

The special elections capped several months of electoral drama.

Republicans held a comfortable 113-90 House majority last year. But once-a-decade redistricting and strong performance in statewide races helped Democrats flip just enough seats in the fall election to win a 102-101 majority in the House. Or so it seemed. Three of those Democratic seats quickly became vacant, casting uncertainty over who actually controlled the chamber.

Democratic state Rep. Tony DeLuca died of cancer in October, shortly before winning reelection. Democratic state Rep. Summer Lee resigned after also winning a congressional election. And Democratic state Rep. Austin Davis quit before being sworn in as lieutenant governor.

That left Republicans with more people in the House than Democrats and led to a political impasse. The chamber elected Democrat Mark Rozzi as speaker in January, but only after Republican leaders and a few other GOP members joined with all Democrats on the vote.

The House has been frozen since Rozzi took over and has not passed internal operating rules, assigned members to committees or approved any legislation. It’s unclear whether Rozzi will retain the speakership when Democrats convene with their newly elected members.

Democrats had been expected to win Tuesday’s special elections, because they had easily won the same seats last fall.

DeLuca’s former seat was won by Democrat Joe McAndrew, 32, a business owner who is a former state House Democratic staffer and the former executive director of Allegheny County’s Democratic committee. Lee’s former seat was won by Abigail Salisbury, 40, a lawyer and Democratic member of the Swissvale Borough Council. Matthew Gergely, a Democrat who works for the McKeesport city government, was elected to succeed Davis.

Get daily updates on local news, weather and sports by signing up for the WTAJ Newsletter

The special elections occurred only after the courts rejected an attempt by the House Republican floor leader, Rep. Bryan Cutler, to prevent two of the contests from being decided on Tuesday.

When the newly elected lawmakers take office, the House may still be one member short of its full complement. That’s because Republican say Rep. Lynda Schlegel Culver won a special election Jan. 31 to fill a vacant state Senate seat.