AUGUSTA, Maine — The Maine House and Senate voted Thursday night to enact a $6.3 billion compromise budget for the two-year cycle that begins July 1.

Each chamber voted twice Thursday on the budget, which legislative leaders plan to have on Republican Gov. Paul LePage’s desk Friday morning. The governor, who has repeatedly vowed to veto the compromise spending plan, has 10 days, excluding Sundays, to act on the budget.

In both votes in both chambers, the number of affirmative votes would be enough — barely — to override a veto and enact the budget by July 1, thereby avoiding a state government shutdown.

The budget compromise temporarily raises the state sales tax from 5 percent to 5.5 percent and meals-and-lodging taxes from 7 percent to 8 percent through June 30, 2015. It restores about 65 percent of the $200 million in municipal revenue sharing that LePage proposed suspending as part of the two-year budget plan he introduced in January.

Most Republicans opposed the tax increases and advocated for deeper spending cuts, especially in public assistance programs. Many Democrats wanted to spend more on education and roll back state income tax cuts enacted by the GOP-led Legislature in 2011, which took effect this year. But enough lawmakers from each party swallowed their dissatisfaction and voted to move forward with what House Speaker Mark Eves, D-North Berwick, called “a responsible bipartisan budget proposal.”

The House voted 102-47 Thursday afternoon to advance the budget, then 102-43 Thursday night to enact it. The 102-vote tally is one vote more than the two-thirds needed to enact the emergency measure in time to take effect on July 1 or override a veto, which LePage has promised repeatedly.

The Senate followed with two 25-10 votes in favor of the budget compromise, hashed out after five months of negotiations among Democrats and Republicans on the Appropriations Committee. After grueling overnight deliberations late last week, that panel unanimously endorsed the budget compromise early Saturday morning. Members of the panel said the deal represents a realistic bipartisan agreement that contains something to displease everyone.

Enough of that bipartisan resignation carried over into floor discussion of the budget Thursday to push the compromise through the House and the Senate, both of which are controlled by Democrats but with majorities that aren’t large enough to pass the critical two-thirds threshold.

Five Republican senators aligned with all 19 Democrats and independent Richard Woodbury of Yarmouth in voting for the budget. The plan must continue to receive support from at least 24 senators in future votes to remain vetoproof.

“This is a budget that’s based on realism, and it’s not a budget that’s based on rhetoric, exaggeration, politics or anything of that nature,” said Sen. Patrick Flood, R-Winthrop, who serves on the appropriations panel. “It’s built so it will work.”

In the House, 23 Republicans joined 77 Democrats and two independents in supporting the budget.

Ten Democrats, 35 Republicans and two independents voted against the budget.

One of the Republicans who voted in favor was Rep. Kenneth Fredette, R-Newport, who is the House Republican leader. Fredette said he knew most Republicans hate the tax increases in the budget as well as cuts to municipal revenue sharing and property tax relief programs that will put pressure on local property taxes.

“Maine people expect their legislators to come to Augusta and make the tough decisions that must be made to move Maine in the right direction,” Fredette said in a floor speech Thursday afternoon. “This budget is a tough budget for Republicans. It contains tax increases and spends more in places where, if I alone were writing this budget, I would be more fiscally conservative. … Time is now short and we, the Legislature, must act to protect the hardworking people of Maine.”

The budget divided GOP leadership in both the House and the Senate.

In the Senate, House Republican Leader Michael Thibodeau of Winterport voted against the budget, while Assistant Senate Republican Leader Roger Katz of Augusta supported it.

Assistant House Republican Leader Alex Willette of Mapleton voted against the budget, and a number of Republican House members, including Rep. Jeff Timberlake of Turner, said that despite the best efforts of the budget-writing Appropriations Committee, they could not support a budget that increases taxes.

“In a divided government you must stay at the table even when you feel most strongly that you want to walk away,” said Rep. Peggy Rotundo, D-Lewiston, co-chairman of the Appropriations Committee. “These were not easy choices in the face of extreme pressure from both the left and the right. We were not sent here to represent our political parties. We represent the people back home, who are tired of partisanship. They just want the government to work when they need it.”

In both chambers, legislative leaders fended off numerous attempts to amend the budget. Many of the proposed amendments were elements of LePage’s budget that the Appropriations Committee removed. Timberlake’s proposal to replace the sales tax increase with a mandate that all state agencies reduce their total budgets by 1.5 percent also failed to muster enough support.

To pave the way for collaboration on the budget, Democratic legislative leaders shepherded through votes Thursday on bills to repay Maine’s $183.5 million Medicaid debt to hospitals and on a merger of the departments of Agriculture and Conservation. It’s not a coincidence that the bill to repay the hospital debt, which LePage has identified as a priority for this legislative session, is expected to arrive on his desk the same day as the budget.

“Lawmakers did the right thing by passing a budget that allows the state of Maine to keep working,” Senate President Justin Alfond,D-Portland, said in a prepared statement. “In divided government, Democrats and Republicans in the Legislature worked together to pass a responsible budget that protects our schools, our property owners and small businesses.”

BDN writer Matthew Stone contributed to this report.