(Reuters) - Major League Baseball (MLB) averted its first labor glitch in two decades, announcing on Wednesday that it had reached a tentative five-year labor agreement with the Players Association subject to ratification by both parties.

The previous collective bargaining agreement (CBA) was to expire on Dec. 1 and a failure to reach a new agreement would have marked at least the temporary end of uninterrupted labor peace since the disruptive players' strike of 1994.

MLB said representatives of the owners and players, who have been negotiating in Irving, Texas would continue to draft the entirety of the tentative agreement and that specific terms would be made available when the process was complete.

The new CBA would run through 2021.

With a midnight deadline looming some four hours away, negotiators from both camps emerged visibly pleased and shook hands in public view before MLB made the official announcement.

Had a deal not been reached, both sides would have had to agree to an extension or the owners could have imposed a lockout that would have frozen trades and free agent signings, and benefits to players.

Among the thornier issues that had to be resolved were the possibility of an international draft, roster sizes, ways to reduce wear and tear on players in the 162-game schedule and changes to both the luxury tax and compensation to teams losing free agents.

A labor action would have been the first since the players' 1994 strike that wiped out the end of the season and the entire postseason including the World Series and delayed the start of the 1995 campaign.

After that bitter battle over the owners determination to install a salary cap, MLB has had 21 years of labor peace which helped spawn a period of dramatic growth.

A luxury tax was imposed based on a team salary threshold aimed at reining in the payroll disparity between big-spending teams and small market clubs, who now also benefit from increased revenue sharing.

Revenues soared from $1.2 billion in 1995 to almost $10 billion in 2016, with the average annual salary of players climbing from $1 million to $4.4 million.

Attendance increased, a second wild card playoff team was added in both the American and National League, richer TV deals were made and MLB successfully mined the emerging digital market.

Competitive balance has been healthy over the course of the five years of the previous CBA, with 21 of the 30 teams having reached the postseason, while small market Kansas City and Cleveland combined to win the last three American League titles.

(Reporting by Larry Fine in New York; Editing by Andrew Both)