Kyle Snyder of Woodbine, Md., helped lead the United States to a comeback Friday in the World Cup wrestling finals in Iran, but the host country won the title in the final match. (Doug Kapustin/For The Washington Post)

The Americans almost didn’t make the trip. Bickering between the United States and Iran over President Trump’s controversial executive order concerning immigrant and refugee travel nearly sank their trip to the highly anticipated World Cup freestyle championship. They were in, out and then in again.

But the U.S. wrestlers finally made it to Kermanshah, Iran, and they reached Friday’s gold medal match. This time, as far as the top spot on the podium was concerned, they were out, in and then out again, as their dramatic comeback fell just short. The United States settled for second place, as the host nation posted a 5-3 victory to claim gold.

The Americans dropped their first four matches of the tournament’s final, before Olympic champions Jordan Burroughs and Kyle Snyder helped mount a comeback. The U.S. team trailed 4-3 entering the day’s winner-take-all final match, in which Nick Gwiazdowski was foiled by Iran’s Komeil Ghasemi, 5-0.

Just reaching Kermanshah felt like an accomplishment of sorts in the wake of the political posturing that had jeopardized the trip earlier this month. After Trump issued his order on travel from seven predominantly Muslim countries, including Iran, the Americans were initially assured that they would be allowed to enter the country. But the Iranian government reversed course and announced the U.S. team would not receive visas. Then, after a federal judge suspended Trump’s order, Iran decided to allow the American squad to enter the country after all.

Political backdrops aside, Friday’s final still presented an intriguing matchup. The two nations also had squared off in last year’s World Cup, where they split four matches but Iran claimed gold with a narrow win on criteria, 17-15.

The Iranians cruised through the early rounds of this year’s tournament, winning 23 of their 24 bouts in the three matches leading into Friday’s final. The U.S. squad, meanwhile, advanced to the finals by beating Azerbaijan, 20-14, on criteria after splitting, 4-4.

On Friday, the Americans struggled to get on the scoreboard, letting Iran race out to its 4-0 lead. Nothing was going right. In the 65-kilogram match, Frank Molinari had jumped up 4-0 on Iran’s Meisam Nasiri but ultimately lost, 5-4; it looked as if it was that kind of day.

Iran needed just one more win to secure gold. But Burroughs outpointed Peyman Yarahmadi, 3-2, and then David Taylor scored a second-round pin over Hassan Yazdanicharati to close the overall gap to 4-2. Burroughs and Taylor were the only Americans to go undefeated on the week.

At 97 kilograms, Snyder, the 2016 Olympic champ who hails from Woodbine, Md., topped Amir Mohammadi by a 6-0 count and brought the U.S. team to within one with just one match remaining.

That brought Gwiazdowski to the mat to face Ghasemi, who won silver at the Rio Olympics last year. The stakes couldn’t have been higher: The winner of the tournament’s final match would take gold.

Ghasemi’s high-crotch takedown allowed him to take a 3-0 lead after the first period. Gwiazdowski was unable to battle back, losing on points.

While the travel drama between the two counties is likely to continue — Trump has promised to issue a revised executive order addressing the matter soon — the World Cup participants hailed the week’s tournament as a politics- and drama-free showcase of wrestling at its highest level.

“More than ever before wrestling has proven it is capable of bringing people and nations together,” Nenad Lalovic, president of United World Wrestling, the sport’s international governing body, said in a statement Thursday.