U.S. officials will allow a group of Afghan girls into the country to participate in an international robotics competition after President Donald Trump intervened, White House spokeswoman Sarah Huckabee Sanders confirmed Wednesday, ending a saga that had sparked international backlash.

Homeland Security Department spokesman David Lapan said the U.S. Citizenship and Immigration Services approved a State Department request for six girls from the war-torn country to be allowed in, along with their chaperone, so they can participate in the competition. The girls' applications for U.S. visas had been denied twice.

The non-profit organizing the competition celebrated the reversal in a jubilant statement Wednesday.

U.S. officials will allow a group of Afghan girls into the country to participate in an international robotics competition after President Donald Trump intervened, White House spokeswoman Sarah Huckabee Sanders confirmed Wednesday. Above, five of the six girls at Herat International Airport on Thursday

The U.S. Citizenship and Immigration Services approved a State Department request for six girls from the war-torn country to be allowed in, along with their chaperone, so they can participate in the competition. Above, the girls at Hamid Karzai International Airport in Kabul on Thursday

The girls' applications for U.S. visas had been denied twice. Above, the girls at Herat International Airport on Thursday

On Wednesday, first daughter Ivanka Trump said she was looking forward to meeting the 'brilliant team of Afghan girls'

'I truly believe our greatest power is the power to convene nations, to bring people together in the pursuit of a common goal and prove that our similarities greatly outweigh our differences,' said Joe Sestak, the president of First Global. He credited 'the professional leadership of the U.S. State Department' for ensuring that all 163 teams from 157 countries, including a team of Syrian refugees, would be able to participate.

The U.S. State Department had declined to comment on why the Afghan team's visa applications were denied, saying that 'all visa applications are adjudicated on a case-by-case basis in accordance with U.S. law.'

A senior administration official said that Trump raised the issue with his national security adviser, H.R. General McMaster, during his trip to Germany last week for the Group of 20 summit, and had asked for additional options. The State Department and Department of Homeland Security came up with several - with the idea of 'paroling' the girls through the Department of Homeland Security ultimately chosen by the National Security Council. The person spoke on condition of anonymity to discuss the private deliberations.

The State Department had declined to comment on why the Afghan team's visa applications were initially denied.' Above, four of the girls at the Afghanistan Robotic House on July 6

A senior administration official said that Trump raised the issue with his national security adviser during his trip to Germany last week. Above, three teens at the Afghanistan Robotic House, a private training institute, on July 2

In this photograph taken on July 2, 2017, teenagers from the Afghanistan Robotic House, a private training institute, work on a robot at the Better Idea Organization center in Herat

The girls wanted to show the world that Afghans could also construct a hand-made robot and they had been deeply disappointed by the initial rejections. Above, teens at the Afghanistan Robotic House on July 2

Parole is a temporary status in which a person who is otherwise ineligible to enter the country is allowed in temporarily because of an emergency or humanitarian purpose, or because it's deemed to be in the public good.

Without the reversal, which was first reported by Politico, the girls would have had to watch via video link from their hometown in western Afghanistan.

The girls wanted to show the world that Afghans could also construct a hand-made robot and they had been deeply disappointed by the initial rejections.

'When we heard that we were rejected we lost hope,' said 14-year-old Sumaya Farooqi. 'We applied again for the U.S. visa and we were rejected again.'

Farooqi and her teammates faced seemingly insurmountable obstacles to even get to a point where they could seek permission to attend. It took them six months to prepare, often working seven days a week, as they constructed a robot that sorts balls, has the ability to recognize orange and blue colors, and can move objects to put them in their correct places.

The girls traveled from their homes in Herat after convincing family members to let them go - no small feat in a country where young girls are often discouraged from pursuing academic study, especially in hard sciences such as math.

They made the 800-kilometer (500-mile) journey to the U.S. Embassy in Kabul twice because their applications were denied the first time, even though that location was targeted by a deadly truck bomb on May 31 in which more than 150 people were killed and more than 400 others wounded.

War-torn Afghanistan has faced a series of large-scale attacks as the Taliban stepped up its war against the Kabul government in this year's summer offensive. In addition, the emerging Islamic State group affiliate in Afghanistan has tried to increase its footprint with attacks in urban areas.

Afghanistan is not part of Trump's order to temporarily ban travel from six Muslim-majority countries. Teams from Syria, Iran and Sudan - which are on that list - were granted visas to compete. Members of the team from Gambia were also granted visas after initially being denied.

First Global, a not-for-profit charity, holds the annual international robotics challenge in hopes of sparking a passion for science and technology among high school students around the world. It is an 'Olympics'-style competition in which one team from every nation is invited to participate. It takes place July 16-18 in Washington, D.C.