Tim Kurkjian breaks down how MLB players and owners were able to reach agreement on a five-year labor contract. (2:41)

It took nearly around-the-clock bargaining over the past two days and nights, but Major League Baseball and its players' union have kept their 21-year streak of labor peace intact for another five years.

Shortly before 9 p.m. ET Wednesday, the two sides reached agreement on a five-year collective bargaining agreement that will run through the 2021 season. The deal was agreed to just over three hours before the previous CBA would have expired at 12:01 a.m. ET Thursday.

The new agreement averts a potential lockout of the players that would have frozen baseball's hot stove and pulled the plug on the major league portion of next week's winter meetings.

By the time the deal was reached Wednesday, the two sides had been negotiating almost continuously for more than 24 hours -- on little or no sleep. It is believed that the final hurdle was an agreement on a new luxury-tax system, in tandem with an end to draft-pick compensation for free agents signed by all but a handful of teams.

In announcing the agreement, MLB said it will make specific terms available when drafting is complete.

"Happy it's done, and baseball is back on,'' Los Angeles Dodgers pitcher Brandon McCarthy said.

Sources said the luxury-tax threshold will jump from $189 million to $195 million next year, then to $197 million in 2018, $206 million in 2019, $209 million in 2020 and $210 million in 2021. Teams that exceed the threshold will pay similar tax rates to the current deal, unless they go way over the threshold, in which case their tax rate could jump as high as 92 percent.

Teams that sign a premium free agent will no longer have to give up a first-round draft pick to the team that lost that player. However, teams with payrolls higher than the luxury-tax threshold would have to surrender a second-and fifth-round pick. All other teams would be required to forfeit their third-round pick.

Teams that lose a free agent who rejects a qualifying offer would still receive a pick. For most teams, that pick would be a sandwich pick immediately following the competitive-balance picks that are awarded after the second round. However, if that team comes from the 15 smallest markets, is receiving revenue-sharing money and loses a free agent who signs a contract worth at least $50 million, that pick would follow the first round. If the team losing the player is over the luxury-tax threshold, the pick would follow the fourth round.

Tony Clark and the MLBPA struck a labor deal with owners that extends the sport's industrial peace to 26 years since the ruinous fights in the first two decades of free agency. AP Photo/Richard Drew

Some additional points to the deal (which covers the 2017-21 seasons), according to ESPN sources and The Associated Press:

The league that wins the All-Star Game no longer will get home-field advantage in the World Series, which instead will go to the pennant winner with the better regular-season record.

Smokeless tobacco will be banned for all new big leaguers.

Although owners pushed for months to include international players in the amateur draft, they dropped that demand this week, sources said. In its place, teams would work under a revised system of bonus pools that would place a hard cap, set initially at approximately $5 million, on the total annual dollars that each club can spend to sign foreign-born amateur players.

The regular season will lengthen from 183 days to 187 starting in 2018, creating four more scheduled off days during the regular season. The sides also have discussed scheduling more day games when teams face long flights following those games.

The minimum salary rises from $507,500 to $535,000 next year, then to $545,000 in 2018 and $555,000 in 2019, with cost-of-living increases the following two years; the minor league minimum for a player appearing on the 40-man roster for at least the second time goes up from $82,700 to $86,500 next year, then to $88,000 in 2018 and $89,500 in 2019, followed by cost-of-living raises.

There will be changes to the revenue-sharing formula, which would affect both payers and recipients. Details of those changes remain unknown.

The sides have discussed numerous changes to the June amateur draft. Those changes could include a revamped slotting system and trading picks. Details have yet to emerge.

As part of the drug agreement, there will be increased testing, players will not be credited with major league service time during suspensions, and biomarker testing for HGH will begin next year.

Changes also are likely to the domestic violence policy. Details have yet to emerge.

Oakland's revenue-sharing funds will be cut to 75 percent next year, 50 percent in 2018, 25 percent in 2019 and then phased out.

The sides have discussed the possibility of playing games outside of North America during the regular season in future seasons. It isn't known where those games would be scheduled, but commissioner Rob Manfred has said publicly that he would like to see regular-season games played in London.

The agreement also would address numerous other issues, including service-time rules, expansion, replay, pace of game, meal money and ways to discourage tanking. However, it might be as long as several weeks until all of those changes will be known publicly.

Baseball had eight work stoppages from 1972 to 1995, the last a 7½-month strike in 1994-95 that led to the first cancellation of the World Series in 90 years. The 2002 agreement was reached after players authorized a strike and about 3½ hours before the first game that would have been affected by a walkout.

The peace in baseball is in contrast to the recent labor histories of other major sports. The NFL had a preseason lockout in 2011, the NBA lost 240 games to a lockout that same year, and the NHL lost 510 games to a lockout in 2012-13.