Southwest Airlines Co. and the union for its mechanics reached an agreement in principle for a new contract Saturday, amid an exchange of lawsuits and more than six years after beginning negotiations.

The proposed five-year accord would give mechanics $160 million in retroactive pay, an immediate 20 percent raise effective April 1, and 3 percent annual increases each August, according to a joint statement from the Aircraft Mechanics Fraternal Association and Southwest. The terms are an improvement from a proposal union members rejected in September, but since increased in part because of the added time they had worked without a new contract .

Southwest secured work rule changes that will allow the low-cost carrier to become more efficient.

The two sides must put the agreement into contract language before it is sent to members for a vote. The accord was reached in the first talks since Southwest sued AMFA, claiming mechanics were engaging in a work slowdown by grounding planes for repairs not related to flight safety. The airline was forced to cancel hundreds of flights at a cost of millions of dollars weekly, Chief Executive Officer Gary Kelly had said.

Aviation regulators warned Southwest and the union on March 8 that their contentious contract talks and legal fight are putting the carrier’s safety at risk. The Federal Aviation Administration urged the two sides in a letter to work cooperatively on safety issues. Southwest flies the most passengers on domestic flights of any U.S. carrier.