Major League Baseball and the sport's governing body in Cuba struck a historic deal on Wednesday, allowing players from the island to play in the big leagues without having to defect, officials said.

The initial deal will run through Oct. 31, 2021, and will allow Cuban players to sign under rules similar to those for players coming from Japan, South Korea and Taiwan, MLB and the Cuban Baseball Federation announced.

"Establishing a safe, legal process for entry to our system is the most important step we can take to ending the exploitation and endangerment of Cuban players who pursue careers in Major League Baseball," said Tony Clark, executive director for the MLB players' union in a statement.

Cuban children train during a baseball practice in Havana on Fen. 7, 2017. Yamil Lage / AFP - Getty Images

Under the agreement, Cuban players who are at least 25 and have played six years in that country's domestic league will be free to sign with an MLB team that will pay a "release fee" to the Cuban club, according to the federation.

"The contract will contribute to stopping illegal activities like human trafficking that for years have put the physical integrity and life of many talented young Cuban baseball players at risk," the Cuban federation said, adding that it took three years to negotiate the deal.

A player who doesn't meet the experience criteria could still come to North America and sign a minor league deal, the Cuban side said.

“For years, Major League Baseball has been seeking to end the trafficking of baseball players from Cuba by criminal organizations by creating a safe and legal alternative for those players to sign with major league clubs,” MLB Commissioner Rob Manfred said in a statement on Wednesday.

New York Yankees relief pitcher Aroldis Chapman throws to a Boston Red Sox batter during the ninth inning of Game 2 of a baseball American League Division Series, in Boston on Oct. 6, 2018. Elise Amendola / AP file

“We believe that this agreement accomplishes that objective and will allow the next generation of Cuban players to pursue their dream without enduring many of the hardships experienced by current and former Cuban players who have played Major League Baseball,” he said.

The Cuban federation and an MLB representative both said the U.S. Department of Treasury has signed off on this deal.

Without such a deal, the only way players from the impoverished, baseball-loving island could play in the big leagues was to defect — which could be a shady, often dangerous journey involving traffickers and criminals.

For example, a Miami jury last year convicted a Florida sports agent and a baseball trainer on charges related to their Cuban smuggling ring.

Yasiel Puig #66 of the Los Angeles Dodgers, from right, is congratulated by Tim Wallach #26 after hitting a solo home run during the first inning of a baseball game against the San Diego Padres at Petco Park in San Diego on June 20, 2013. Denis Poroy / Getty Images file

Baseball players testified at the trial of Bartolo Hernandez and Julio Estrada, describing the perils of defecting from Cuba.

Then-Seattle Mariners outfielder Leonys Martin told jurors he narrowly escaped from crowbar-wielding kidnappers in Mexico before walking across the U.S. border in Laredo, Texas. Martin has made more than $26 million in his eight-year pro career.

Some of the most notable Cuban defectors to play Major League Baseball include Livan Hernandez (1996-2012), his brother Orlando “El Duque” Hernandez (1998-2007), Yoenis Cespedes (2012-present), Yasiel Puig (2013-present) and Aroldis Chapman (2010-present).