DALLAS — Southwest Airlines and a union representing its mechanics could be on the verge of ending a bitter, long-running labor dispute that has triggered hundreds of flight cancellations and raised safety concerns.

The two sides announced the tentative contract agreement late Saturday after six years of negotiations between Southwest LUV, -1.48% and the Aircraft Mechanics Fraternal Association.

The deal still needs to be voted on by the roughly 2,400 mechanics who will receive a 20% raise if the contract is approved. The five-year contract also calls for $160 million in bonuses for the mechanics.

The agreement, reached in a week of mediation, came after the Federal Aviation Administration warned that the deteriorating relationship between Southwest and its mechanics threatened to undermine the airline’s safety-management system.

Southwest had complained about mechanics flagging minor maintenance issues to force unnecessary flight cancellations for things such as missing seat row numbers.

The number of canceled flights had jumped to 62 a day in February, from the normal 14, according to a lawsuit that Southwest filed against the mechanics union for what it alleged was an illegal work slowdown designed to pressure the airline into agreeing to a contract.

Southwest CEO Gary Kelly had said the flight cancellations were costing the airline millions of dollars.

The union had filed its own lawsuit accusing Southwest and its chief operating officer of defamation.

Both sides issued conciliatory statements Sunday but declined to discuss how the tentative agreement might affect their respective lawsuits.

“Our mechanics certainly deserve a new contract, and this industry-leading agreement in principle addresses our employees’ interests,” said Russell McCrady, Southwest’s vice president of labor relations.

“I commend both sides for their hard work and tireless negotiating this past week,” said Bret Oestreich, national director for the mechanics union.