TORONTO — Hector Barajas, a U.S. Army veteran, spent years trying to get back into the United States after being unexpectedly deported to Mexico in 2004.

It turns out his border battles weren’t over.

Barajas, who served in the Army’s 82nd Airborne Division, was denied entry late Friday to Canada where he was to appear at a film festival to tell his story. Saturday evening, Canadian border authorities allowed him in, but offered no explanation for why he was kept out in the first place and did not reply to a request for clarification on its later decision.

Barajas is a principal subject of “Ready for War,” a documentary set to make its world premiere at the Toronto International Film Festival on Sunday. The movie, which counts the rapper Drake as an executive producer, tells of the hundreds of U.S. green-card holders deported to Mexico after serving overseas in the U.S. armed forces.

Barajas, who now lives in Los Angeles after 14 years in exile in Mexico and is now a U.S. citizen, was denied entry to Canada as he sought to drive across the New York-Ontario border. It was a surprise development that illustrates the capriciousness of border policies the movie seeks to document.

“This is emblematic of the life that Hector and many others like him have to live,” Andrew Renzi, the film’s director, who has been in close touch with Barajas, said from a hotel here Saturday morning. “A man lives a life of altruistic service, and he’s repaid by a border policy that doesn’t make any sense.”

Renzi said Barajas spent Friday night at a Buffalo-area motel before trying again to enter Canada.

Judith Gadbois-St-Cyr, a spokeswoman for Canada’s Border Services Agency, said as a matter of law the agency does not “provide comment or provide details on specific individual cases” but added “Admissibility of all travelers is decided on a case-by-case basis and based on the information made available at the time of entry. Several factors are used in determining if an individual is admissible to Canada, including involvement in criminal activity, human rights violations, organized crime, security, health or financial reasons.”

Thom Powers, who runs the documentary section at TIFF, as the festival is known, did not reply to a request for comment. Showtime, which is planning to broadcast the film later this year, confirmed Barajas had been allowed into Canada and would appear Sunday at the screening. It was unknown if Canadian authorities had discussed Barajas’s situation with U.S. counterparts.

Barajas was allowed to return to the United States in 2017 and was granted U.S. citizenship in 2018.

The movie examines the Mexican-born, U.S. veterans — Renzi said there are thousands; ICE has not provided official numbers — who believed they would automatically be given citizenship after enlisting. The men and women completed their service and were honorably discharged.

But as the film shows, the veterans were deported. The events unfolded after they served jail time for crimes committed after their service. But where U.S. citizens would simply be released after serving jail time, these veterans were sent to Mexico.

Upon arriving south of the border, many of the veterans, still suffering from PTSD, fall into homelessness or addiction. Others are recruited by drug cartels, who covet their military training. Renzi and his team embedded in Juarez and other parts of Mexico with the cartels. One man known as El Vet, is also a key figure in the film; he is shown using his gun training to kill for a cartel.

Barajas took a different path. His family emigrated from a Mexican farming community to Compton, Calif., when he was seven. He enlisted, seeking a brighter future than the one his neighborhood afforded.

Barajas was convicted of discharging a firearm, served his sentence and was deported upon release. After arriving in Tijuana he fell into addiction before seeking help and recovering. He has since started a center for deported veterans in Mexico known as “The Bunker” that provides counseling and job training, among other services.

“This can’t be. You served in the military. How can they deport you?” Barajas says in the film, which The Washington Post was shown. “I still consider myself an American, a patriot; I will keep fighting to go home. I’m proud of my service. I wouldn’t take it back if I had to do it all over again. I would serve my country, put my life on the line.”

In the film, before he is granted entry back into the U.S., the veteran is shown for years as separated from his daughter, in grade school in Southern California; he is forced to Skype with her as their sole means of contact.

He was allowed to return to the United States after California Gov. Jerry Brown (D) pardoned him on the weapons charge.

Tammy Duckworth, the Democratic U.S. senator from Illinois who served and was wounded in Iraq, said the issue of deported veterans remains a black mark on the country’s immigration policy

“Most Americans would be surprised to know that we deport veterans,” Duckworth, herself born in Thailand, says in the film. “We now have a population of American veterans who are still deserving of veterans benefits who can’t get access to them and can’t even come back to the country that they defended.”

The movie shows the efforts of Duckworth and Nathan Fletcher, a veteran and former California assemblyman behind the group Honorably Discharged, Dishonorably Deported, to bring back the veterans. (It usually involves seeking a pardon, which expunges the record and reverses the deportation.)

Drake became involved with the film after his managers were made aware of the teaser via Renzi’s editor, Ben Wolin. The rapper is expected to appear on the red carpet for the film Sunday.

Renzi says the issue transcends the divide of Democrats and Republicans. The policy of deporting veterans for crimes “of moral turpitude” began under President Bill Clinton and has continued under administrations from both parties.

He does believe the tougher enforcement policies of ICE during the Trump era have given some vets a harder road. One subject in the film, a diehard Bears and Cubs fan from Chicago named Miguel Perez, was recently deported. Renzi believes he faced a more aggressive process because Trump-era ICE did not want to appear to go easy on subjects.

“This is a bipartisan offense that, wildly enough, can be a bipartisan fix,” Renzi said. “Right now the immigration conversation is exhausting, loud and confusing for a lot of people. This feels very specific — and something people on the right and left can get behind, because it involves veterans and Mexican Americans.”

The solution, he said, could begin with Barajas being granted entry to Canada.