KABUL, Afghanistan — When six Afghan teenage girls were denied U.S. visas to enter an international robotics contest in Washington set for later this month, the unexplained decision seemed to be punishing the very ambitions U.S. agencies have long advocated for girls in Afghanistan, where many are denied educational opportunities.

But the story is more complicated than that.

Afghanistan, beset by insurgent violence and economic uncertainty, is suffering from a massive brain drain, according to Afghan and U.S. officials. Scholarship students, academic fellows and teachers who receive temporary visas to visit the United States often vanish into immigrant communities instead of returning home.

The growing phenomenon has made U.S. officials especially wary of approving visa requests – even for applicants like the robotics students who may otherwise deserve them – if they decide there is a risk the person will fail to return home.

“It is sad to say, but some of them do not come back,” said Elham Shaheen, a senior official at the Ministry of Higher Education who manages foreign-study policies. He said 10 percent of all Afghans who are awarded temporary visas for academic purposes in the United States or Europe defy immigration rules to remain there permanently.

Female students and faculty members, facing extra frustrations at home, are no exception. Several years ago, Shaheen said, 12 female university lecturers won scholarships to obtain MA degrees in economics in Germany. Of the 12, he said, “11 of them escaped.”

American officials here and in Washington have refused to discuss the case of the robotics team, but several pointed out that U.S. law “presumes” all temporary visa seekers intend to remain in the United States unless they are able to prove they have compellingly strong ties to their country.

Two members of the team, interviewed Thursday from their home city of Herat, said U.S. consular officers had asked about their ties to Afghanistan, whether they had relatives in the United States and whether they intended to return home after the competition.

Youth teams from about 150 countries will face off next week in the FIRST Global Challenge contest, created to promote international student interest in science, technology and math. Only one other team, from Gambia, was turned down.

“Each of us gave them written guarantees from two government employees vouching for our return,” said Rodaba Noori, 16, a member of the Afghan team that built a ball-sorting robot. “This is our country. We have our life and family here,” she said. “How could we abandon them and not return after the competition?”

Obtaining a visa, though, is just the last of many daunting hurdles the female students face in their efforts to advance academically– long before they can even dream of traveling abroad.

Afghan families often oppose their daughters attending universities in Kabul or other cities, fearing for their safety and exposure to young men.

Agencies that offer domestic scholarships, such as the nonprofit Asia Foundation, often have to negotiate with families or agree to support a male relative who can accompany the girl each semester.

Girls are also at a disadvantage in English and math, because Afghan families are more willing to pay for boys to take private classes. As a result, more girls fail college-entrance exams. To help even the balance, USAID sponsors exam-prep classes for girls, and education officials have established a 30 percent female quota for all in-country scholarships.

“There is a chain of barriers for Afghan girls that requires a network of support to overcome,” said Razia Stanikzai of the Asia Foundation in Kabul, whose job is to promote Afghan female students’ participation in science and technology.

Many Afghans, however, view these as “male” fields, and families may try to steer daughters into nursing or teaching instead.

To overcome such stereotypes, Stanikzai’s program sponsors science fairs at provincial schools, where girls demonstrate projects to fathers and male community elders. “We don’t want girls sitting at home and being told that science and technology are for boys,” she said.

Even students at such elite institutions as the American University in Afghanistan, where the U.S. Embassy has funded more than 400 scholarships for women, face prejudice. Two female information technology students said that in most of their classes, all of the other students were male and that some of their friends and relatives had no idea what they were studying – or why.

“Some of them tell us to change majors, to do something more acceptable like nursing or arts,” said Shamim Ali, 26, whose dream is to start her own IT company. “This is a traditional society, and even the concept of IT is strange. People think we are going to become mechanics or electricians and climb up on ladders.”

When it comes to studying abroad, there are many opportunities, such as the Fulbright program, which has sent 535 Afghan students – among them, 102 women – to the United States since 2002. There are also closer international universities in countries such as India, Iran and Bangladesh, which Afghan officials are promoting as cheaper, more comfortable places to study at a time of growing anti-Muslim sentiment in the West.

Yet even accomplished female students can be thwarted by family resistance and competing cultural priorities.

Education officials described cases in which applicants for foreign scholarships turned out to be married, pregnant and unable to accept by the time their tickets and visas came through.

One woman in Kabul named Raihana, 27, who obtained a scholarship to study economics in Bangladesh, said her older brother, the senior male in the family, at first refused to let her to go, but her younger and more liberal brother finally persuaded him.

“Since my father was dead, he felt he had to take responsibility for me and my safety,” the woman said, “but the real reason was that he was married and he did not want his wife to study or travel. If I went, she would be jealous and complain.”

The members of the robotics team said they, too, encountered initial resistance from their parents – not only to travel to the United States for the robotics contest, but also to fly cross-country to Kabul, with its constant news of insurgent bombings, to apply for their visas.

“We finally convinced them, and in the end they were very happy, but it was a difficult path,” said Yasamin Yasinzada, 16, who said her dream is to “be a pioneer in robotics and set an example for other girls.” She said it was “much easier for boys, because they are allowed to travel, but it helped that our coach was going with us.”

Despite her disappointment at being turned down to visit the United States, where the robot will now appear at the competition without its creators, Yasinzada said she still hopes to study abroad.

“The specific place doesn’t matter,” she said. “I just want to learn, interact, see other ways of life, come back home and put it all into practice.”