BOSTON -- The House and Senate on Wednesday signed off on a compromise bill overhauling the marijuana legalization ballot law, moving the long-awaited deal a step closer to Gov. Charlie Baker's desk.

The committee of House and Senate negotiators had planned to produce a deal by June 30, but talks dragged on this month amid disagreements over tax rates, local control and other issues. Final votes in each branch are expected Thursday when the Senate plans to more thoroughly discuss the accord, the product of competing House and Senate bills reconciled in secret by the conference committee over more than three weeks.

Baker, who opposed Question 4 legalizing recreational marijuana, should now be in recept of the bill by week's end, but it's unclear whether he might have any additional recommendations that could be proposed in the form of amendments that would further delay the implementation of the law.

The governor has said he wants to see the updates in place soon so the regulatory structure can be developed, and has said he biggest preference in the setting of a tax rate is that it be sufficient to cover the costs of marijuana regulation. He has also pointed to local control and restrictions around packaging and potency of edible products as priority areas for him in the legislation.

Ultimately, conferees settled on a 10.75 percent excise tax on retail marijuana sales, on top of the state's 6.25 percent sales tax. Cities and towns would be able to tack up to 3 percent more on each sale within their borders, and medical marijuana will remain untaxed. The compromise raises the maximum tax rate on retail pot sales to 20 percent, up from 12 percent in the existing ballot law.

The bill also allows cities and towns that supported the 2016 legalization ballot initiative to ban marijuana stores only if a majority of voters approve, while letting local governing boards ban the shops in cities and towns that voted against Question 4 in November 2016.

Majority Leader Ron Mariano, the lead House negotiator, said the conference was "extremely long and difficult," taking many hours because the lawmakers were seeking to balance three documents with different viewpoints: the House bill, the Senate bill and the original ballot question.

"This was an extremely technical bill that required an awful lot of exchanges between the House and the Senate," Mariano said.

The bill also contains restrictions on packaging, advertising and marketing of marijuana products, including what Rep. Hannah Kane, a Shrewsbury Republican who served on the conference committee, called a first-in-the-nation ban on marijuana advertisements unless at least 85 percent of the audience is 21 or older.

"This element of the bill will make a real and substantive impact on what our youth see and hear in terms of marketing marijuana, and we know less exposure means less use by our youth," she said.

The House accepted the conference report (H 3818) by a 136-11 vote, with 14 representatives switching their position from the 126-28 vote on the initial House bill. Rep. Diana DiZoglio, a Methuen Democrat, was the only one to move from a yes to a no, telling her colleagues that she could not back the compromise because it left out certain House-backed funding dedicated to substance abuse prevention and education.

In the 38-member Senate, the deal was accepted on a 15-5 standing vote. Democrat Sen. John Keenan and Republican Sens. Bruce Tarr, Donald Humason, Vinny deMacedo and Patrick O'Connor stood in opposition.

Tarr, the minority leader, said the Senate would take a recorded vote on Thursday to send the bill to Baker.

"We're going to have a roll call and a full debate tomorrow," the Gloucester Republican told the News Service. He said the decision to accept the conference report with a standing vote was "about accepting the wishes of some to be able to move this through the process. A standing vote indicates that there is opposition. That opposition will become more fully formed and explained tomorrow."

Once the bill hits Baker's desk, he will have 10 days to review it, which would likely give him until the end of the month to sign, veto or amend the bill.

About 54 percent of voters in November agreed to legalize and regulate the use, possession and sale of marijuana by people age 21 and older. Much of the law has not yet taken effect after lawmakers and Gov. Baker in December delayed by six months the portions dealing with commercial marijuana sales to give them time to make changes, pushing the expected start of retail sales to July 2018.

Treasurer Deborah Goldberg issued a statement on Wednesday addressing some of her office's responsibilities under the bill, noting she is "responsible to appoint several members with marijuana expertise to the Cannabis Advisory Board by August 1, 2017."

"Additionally, by September 1, 2017, we will appoint the Chair to the CCC and take part in two joint appointments to the Commission with the Governor and Attorney General," Goldberg said. "We are dedicated to finding people who are committed to ensuring a safe and timely implementation of this new industry in Massachusetts and we wish them every success in their efforts."

The Massachusetts Medical Society, which had opposed legalizing adult use of marijuana, called the compromise bill a "significant step forward."

"Inclusion of public health experts within the Cannabis Control Commission structure and funding earmarked for public and behavioral health, prevention, treatment, intervention and critical research related to marijuana use demonstrate a focus on the health of the people of Massachusetts," society president Dr. Henry Dorkin said in a statement. "We are encouraged by the labeling and packaging requirements and the incorporation of warnings on marijuana products, as well as marketing and advertising restrictions in place to reduce youth consumption."

Andy Metzger contributed reporting.