WHEN terrorists in Nigeria organized a secret attack last month, they didn’t target an army barracks, a police department or a drone base. No, Boko Haram militants attacked what is even scarier to a fanatic: a girls’ school.

That’s what extremists do. They target educated girls, their worst nightmare.

That’s why the Pakistani Taliban shot Malala Yousafzai in the head at age 15. That’s why the Afghan Taliban throws acid on the faces of girls who dare to seek an education.

Why are fanatics so terrified of girls’ education? Because there’s no force more powerful to transform a society. The greatest threat to extremism isn’t drones firing missiles, but girls reading books.

Nicholas Kristof

DAMON WINTER / THE NEW YORK TIMES

In that sense, Boko Haram was behaving perfectly rationally — albeit barbarically — when it kidnapped some of the brightest, most ambitious girls in the region and announced plans to sell them as slaves. If you want to mire a nation in backwardness, manacle your daughters.

What saddens me is that we in the West aren’t acting as rationally. To fight militancy, we invest overwhelmingly in the military toolbox but not so much in the education toolbox that has a far better record at defeating militancy.

President Obama gives the green light to blow up terrorists with drones, but he neglects his 2008 campaign promise to establish a $2 billion global fund for education. I wish Republicans, instead of investigating him for chimerical scandals in Benghazi, Libya, would shine a light on his failure to follow through on that great idea.

So why does girls’ education matter so much? First, because it changes demography.

A classroom in Mali.

SUSAN MEISELAS / MAGNUM PHOTOS (2007)

One of the factors that correlates most strongly to instability is a youth bulge in a population. The more unemployed young men ages 15 to 24, the more upheaval.

One study found that for every 1 percentage point increase in the share of the population aged 15 to 24, the risk of civil war increases by 4 percent.

That means that curbing birthrates tends to lead to stability, and that’s where educating girls comes in. You educate a boy, and he’ll have fewer children, but it’s a small effect. You educate a girl, and, on average, she will have a significantly smaller family. One robust Nigeria study managed to tease out correlation from causation and found that for each additional year of primary school, a girl has 0.26 fewer children. So if we want to reduce the youth bulge a decade from now, educate girls today.

More broadly, girls’ education can, in effect, almost double the formal labor force. It boosts the economy, raising living standards and promoting a virtuous cycle of development. Asia’s economic boom was built by educating girls and moving them from the villages to far more productive work in the cities.

One example of the power of girls’ education is Bangladesh, which until 1971 was (the seemingly hopeless) part of Pakistan. After Bangladesh gained independence, it emphasized education, including of girls; today, it actually has more girls in high school than boys. Those educated women became the backbone of Grameen Bank, development organizations like BRAC and the garment industry.

Likewise, Oman in the 1960s was one of the most backward countries in the world, with no television, no diplomats and radios banned. Not a single girl attended school in Oman. Then there was a coup, and the new government educated boys and girls alike.

Today, Oman is stable and incomparably better off than its neighbor, Yemen, where girls are still married off young and often denied an education. America is fighting Al Qaeda affiliates in Yemen and Pakistan with drones; maybe we should invest in girls’ schools as Bangladesh and Oman did.

Girls’ education is no silver bullet. Iran and Saudi Arabia have both educated girls but refused to empower them, so both remain mired in the past. But when a country educates and unleashes women, those educated women often become force multipliers for good.

Angeline Mugwendere was an impoverished Zimbabwean girl who was mocked by classmates because she traipsed to school barefoot in a torn dress with nothing underneath. She couldn’t afford school supplies, so she would wash dishes for her teachers in hopes of being given a pen or paper in thanks.

Yet Angeline was brilliant. In the nationwide sixth-grade graduation examinations, she had the highest score in her entire district — indeed, one of the highest scores in the country. Yet she had no hope of attending seventh grade because she couldn’t afford the fees.

That’s when a nonprofit called the Campaign for Female Education, or Camfed, came along and helped pay for Angeline to stay in school. She did brilliantly in high school and is now the regional director for Camfed, in charge of helping impoverished girls get to school in four African countries. She’s paying it forward.

Educating girls and empowering women are also tasks that are, by global standards, relatively doable. We spend billions of dollars on intelligence collection, counterterrorism and military interventions, even though they have a quite mixed record. By comparison, educating girls is an underfunded cause even though it’s more straightforward.

Readers often feel helpless, unable to make a difference. But it was a grass-roots movement starting in Nigeria that grabbed attention and held leaders accountable to address it. Nigeria’s leaders perhaps now realize that they must protect not only oil wells but an even greater treasure: the nation’s students.

Likewise, any of us can stick it to Boko Haram by helping to educate a girl. A $40 gift at Camfed.org buys a uniform so that a girl can go to school.

We can also call on members of Congress to pass the International Violence Against Women Act, which would elevate the issue of sexual violence on the global agenda.

Boko Haram has a stronghold in northeastern Nigeria because it’s an area where education is weak and women are marginalized. Some two-thirds of women in the region have had no formal education. Only 1 in 20 has completed high school. Half are married by age 15.

Obviously, the situation in the United States is incomparably better. But we have our own problems. It’s estimated that 100,000 girls under 18 years old in the United States are trafficked into commercial sex each year. So let’s fight to #BringBackOurGirls in Nigeria but also here in the United States and around the world.