Massachusetts lawmakers steamrolled Gov. Charlie Baker's veto of pay raise legislation Thursday, delivering big salary increases for themselves, six statewide constitutional officers, and scores of judges.

In a turn of events that no one was predicting heading into the new year, the Democrat-controlled Legislature in just over three weeks surfaced the idea of pay raises for public officials and then rammed the bill through authorizing the increases, which are worth about $18 million per year, tacking on language ensuring that the larger paychecks occur right away.

On Thursday, lawmakers completed their work by overriding Gov. Baker's veto of the bill by votes of 116-43 in the House and 31-9 in the Senate. No members of either branch changed their vote in the week between the bill's passage and Thursday's veto override.

Lawmakers entered the new year with major policy challenges on their agenda, ranging from rising health care costs to the new marijuana law, and calls for criminal justice and sentencing reforms. House Speaker Robert DeLeo and Senate President Stanley Rosenberg, who in December expressed interest in saving state services unilaterally axed by Baker, jointly decided to vault the pay raise bill to the top of the agenda, and pushed the bill through without holding a public hearing on it and in the face of objections from Baker who said the bill was "fiscally irresponsible" and would boost state pension costs.

Baker on Thursday called the pay bill a "very rich package" of raises that deserved "more time and visibility" as the first matter to be taken up by the Legislature in the new year, and said it will require his administration to "figure out how to pay for it." House and Senate leaders have said the $2.8 million for lawmakers can be absorbed into existing budgets for those branches, but the salaries of judges could require additional funding.

The governor said the "big beef" he heard the most from people calling his office was not the idea of a pay raise, but the "size and scale" of the raises pursued by Democratic leaders. "It's pretty hard to justify given where we are as a commonwealth and the fact that there's still a lot of programs that people would like us to fund and a lot of stuff that people would like us to support," he said.

Baker and Lt. Gov. Karyn Polito plan to turn down the pay raises for themselves, as well as the $65,000 housing allowance for the governor. "There's still a lot of people in Massachusetts who are struggling and hurting and I think its important that we, sort of, stand by them," Baker said.

Legislators spent little time in recent days publicly arguing for the salary hikes, but when they have spoken out they have argued that the roughly $62,000 base salary of lawmakers is too low and biennial adjustments based on changes in median income have been insufficient. Pay raise supporters said they want to attract the most qualified people to serve in the Legislature and noted many lawmakers have left public service because the wages are too low.

Last week, Senate President Stanley Rosenberg said the bill would provide needed updates to the compensation of lawmakers, which starts at a base salary of about $62,000. While base pay rates of legislators are adjusted every two years based on changes in median income — including earlier this year — proponents defended the pay raises, arguing that stipends for leadership and senior committee positions had not been adjusted since either 1982 or 1994.

"We are losing young people every election cycle," Rosenberg told reporters. He said, "Particularly the younger members who are trying to start families and start their own career - they cannot live on this."

Government payrolls are increasingly littered with workers earning more than $100,000 per year and the raises will catapault some lawmakers above that mark, while leaving others under it and, at the high end, delivering $45,000 pay raises to DeLeo and Rosenberg that will push their salaries over $142,000.

Reps. Jonathan Hecht of Watertown, Shawn Dooley of Norfolk, and James Lyons of Andover were the only representatives to take the floor and debate the pay raises prior to the override vote. They all spoke against passing the bill, with Dooley saying it was precedent-setting and would add to the power of the House Speaker by enabling him or her to decide how much House members receive in their paychecks.

Rep. Hecht said the raises would make the House "more unequal, more hierarchical and less representative." The Watertown Democrat said only nine House members received extra pay before 1977, a number that rose to 28 in the late 1970s, 34 in the mid-1990s, and 55 in recent years. That number will rise to 80 under DeLeo's plan, Hecht said, or two thirds of the majority party members.

With nine separate pay levels among House members, Hecht speculated that House members will become more concerned about the desires of House leaders who decide which representatives get extra pay than about their constituents' concerns.

The biggest raises will come in the form of fattened stipens for lawmakers with specially designated leadership duties, but all lawmakers, regardless of their rank or seniority, will be entitled to receive more money for their "expenses" — $7,800 or $12,800 more, depending on how close they live to the State House. The bill eliminates the per diem payments that have been available to lawmakers for each day they travel to the State House.

Debate in the Senate was limited to brief comments from Senate Minority Leader Bruce Tarr, who said, "It is clear that the governor has reviewed this matter and decided it is inadvisable." The Gloucester Republican said his caucus agreed with the governor's assessment and would be voting to sustain Baker's veto.

Boston Mayor Martin Walsh said Thursday his former colleagues in the Legislature deserve a raise.

"Everyone will say it's a big pay day," Walsh told reporters after attending a bill-signing ceremony in Baker's office. "Obviously I can't deny it's a significant increase, but again, if you take it over a 30-year period and you average it across, it's not as significant."

Walsh said lawmakers have not had a pay increase in years and that his salary dropped in his last two terms as a state rep.

With additional reporting by the State House News Service's Katie Lannan and Matt Murphy