Updated from 11:57 a.m. EDT

UAL's

United Airlines

has hashed out a new contract with its ground workers' union, averting a possible strike and bringing the airline closer to achieving an important labor savings goal.

The news comes hours after the airline's mechanics approved a new contract of their own.

A United spokeswoman confirmed Tuesday the airline had reached an agreement in principle with the International Association of Machinists and Aerospace Workers, which represents some 19,500 United ground workers, primarily gate agents and baggage handlers.

TheStreet Recommends

Both sides had been meeting feverishly ahead of a Tuesday afternoon bankruptcy court hearing on whether to cancel the union's existing contract and impose concessions. The IAM had threatened to strike if the court terminated its contract.

The bankruptcy judge is now giving the parties until June 17 to finalize their agreement, which must be ratified by union rank and file.

"We are pleased to reach this agreement in principle with the IAM, which if ratified will effectively bring to a close a major phase of our restructuring," said Jean Medina, the United spokeswoman, in a statement. An IAM spokesman couldn't be reached for comment.

The IAM was the last United union to agree to a new contract. United has been seeking a total of about $700 million in annual labor savings, saying that amount is necessary to round up financing to exit Chapter 11. United, which has been in bankruptcy protection since December 2002, already extracted $2.5 billion worth of concessions from employees two years ago.

Earlier Tuesday, members of the Aircraft Mechanics Fraternal Association, which represents about 6,800 United mechanics, ratified a new contract designed to save the struggling carrier $96 million a year.

AMFA negotiators reached the new contract with management in mid-May. Concessions include a 3.9% wage cut and a reduction in sick-time pay.

In January, AMFA members rejected a previous agreement with the airline, but the possibility that the bankruptcy court might cancel the union's existing contract and impose harsher concessions may have convinced mechanics to vote "yes" this time around.

United shares rose 18 cents to $1.33.