A group of six girls from western Afghanistan will be able to attend an international robotics competition for which they had spent months preparing after the United States this week reversed a decision to deny them entry to the country.

The team, from Herat, the third-largest city in Afghanistan, is expected to lead a procession of teams from 157 countries into Constitution Hall in Washington on Sunday night, according to the event organizers.

The girls, who are ages 14 to 16, had twice been denied visas, according to Joe Sestak, the former Pennsylvania congressman and Navy admiral who now is president of First Global, the nonprofit organizing the event. But thanks to the help of officials in Washington and, reportedly, the intervention of President Trump, they were ultimately able to secure entry. Another team, from Gambia, was also approved this week after an earlier denial.

“Every team has now gotten through, whether it’s Iran, Libya, and even after the reinstitution of the executive order on travel, we still got Yemen and Syrian refugees through,” Mr. Sestak said, referring to the president’s ban on most visitors from six predominantly Muslim countries, including Yemen and Syria but not Afghanistan.