With protesters knocking on the doors to locked galleries, the North Carolina Legislature pushed through legislation aimed at dialing back the powers of the incoming Democratic governor and reorganizing the state’s elections oversight body.

The legislature, meeting in a last-minute, year-end special session, approved a proposal along party lines Friday that will effectively give Republicans control of the State Board of Elections during election years. Outgoing Republican Gov. Pat McCrory signed the bill into law Friday, without issuing any comment on the drama that has been wracking North Carolina politics since Wednesday.

Lawmakers also passed a bill that, for the first time in decades, will require the governor to get approval from the State Senate for his Cabinet appointees and will end his ability to appoint members to the board of trustees of the powerful University of North Carolina System. The measure will also drastically reduce the number of state employees the governor can directly hire and fire, from 1,500 to 425.

“Why does it make sense to enable the mass political firing of people who have been doing a wonderful job for the state?” Republican Senate President Pro Tempore Phil Berger asked in a statement.

The bills were just two of several aimed at reducing the governor’s influence in state government, the judicial branch, the education system and elections oversight, while strengthening the GOP-dominated Legislature’s influence in all of those areas.

The fast-moving events in Raleigh caught Democrats by surprise.

McCrory convened lawmakers this week to pass a $200 million relief package for Hurricane Matthew and wildfire cleanup. Afterward, GOP lawmakers swiftly called their own special session dedicated to the governmental changes.

Friday’s votes came two weeks after McCrory conceded to Democratic Attorney General Roy Cooper in the nation’s closest gubernatorial race of 2016, winning by about 10,000 votes out of more than 4 million cast.

Republican legislative leaders said the changes were long overdue to realign constitutional power in the state, though they admitted that the Democrat’s election had accelerated their timetable.

Democratic lawmakers and activists derided Republicans’ effort as a “power grab” and urged North Carolinians to come to Raleigh to protest.

Hundreds of protesters heeded Democrats’ calls and packed the capitol on Thursday and, to a lesser degree, on Friday. Police arrested more than 50 people after they refused to stop booing, chanting and cheering from the public galleries while lawmakers debated the bills. At a news conference Thursday, Cooper warned Republicans that they could be overstepping their bounds, politically if not constitutionally.

“This is about thwarting the governor’s ability to move us forward,” he said, promising to sue lawmakers for passing any law he deemed unconstitutional.

McCrory was the only governor in 2016 to lose his seat and the only governor in North Carolina history to lose re-election.