After months of butting heads, the MBTA and the union that represents its bus mechanics have come to terms on a new collective bargaining agreement, one that T officials say will save the system more than $60 million over the next decade, and that an organized labor official said marks "a bellwether moment" for labor relations in Massachusetts.

The T and Machinists Union Local 264 have been at loggerheads over outsourcing the work of some MBTA bus maintenance garages, but the new agreement protects the work currently being performed by union members and spells the end of the debate over bus maintenance privatization. The deal was ratified Sunday by the union.

"This new agreement adheres to the Board's priority, which was to achieve savings and other improvements through agreement with Local 264," Joseph Aiello, chairman of the T's Fiscal and Management Control Board, said in a statement. "This agreement, combined with significant cost savings the T has already achieved through internal management changes, means the Board does not need to further consider contracting out current bus maintenance operations at this time."

MBTA officials said the transit system, which has an extensive backlog of repair needs, could save significant money by turning to the private sector to handle some of the $132 million spent annually to keep its bus fleet in working order. The T solicited bids for bus maintenance at three garages and the machinists union launched a campaign to discredit what it said was the only company to bid on the work.

As part of the new agreement, details of which were disclosed for the first time Monday, the union will continue to provide maintenance of the MBTA's current fleet of 955 buses but the T will still be able to "explore ways to further reduce costs on bus maintenance beyond the current fleet," the T said.

"The fact that all current and potential replacement garages will be staffed by the high quality, Local 264 workforce is a major win for all stakeholders, including for the MBTA as a system," IBEW Local 103's Lou Antonellis said in a statement on behalf of the INVEST NOW Coalition, which had promoted the machinists union's cause. "This is a bellwether moment for Massachusetts -- demonstrating the power of when community and unions work together to protect a public resource that should remain under public control."

Gov. Charlie Baker said Monday afternoon the negotiations with the machinists union were "very long and difficult" but that the final product is a deal with widespread benefits.

"I believe that the contract ... is a big win for everybody. I think it's a win for the riders, I think it's a win for the taxpayers, I think it's a win for the T and a win for the folks who work in the garages," Baker said. "There was a tremendous amount of work done by the T and by the members at (Local) 264 over the course of the length of that negotiation that demonstrated that they, working together, could come up with a variety of ways to dramatically improve both the workmanship and how fast they could get it done and how much it would cost."

The T expects the new deal, which revises and extends the current contract through June 30, 2021, will save money through a variety of workplace reforms and a restructuring of wages for some bus mechanics.

The agreement calls for the adoption of an overtime trigger that will allow union members to collect overtime pay only after they have worked a full 40 hours of regular weekly work and will make it possible for mechanics to work four 10-hour days a week rather than working five eight-hour days.

The T will establish and then enforce standard repair times for all "measurable maintenance tasks" at bus maintenance garages and all machinists will be required under the new agreement to obtain Transit Bus Automotive Service Excellence (ASE) certifications in order to receive promotions and raises.

About 14 months ago, the T reached a new deal with Carmen's Union Local 589 — its largest union — that eliminated the possibility of the T outsourcing the work of driving buses or operating trains on the T's current system.