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.

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 Barack Obama gives the greenlight 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.

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 found that for each additional year of primary school, a girl has 0.26 fewer children.

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.

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 younger than 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.