© dai kurokawa/EPA/Shutterstock

The time-tested method of repelling locusts from crops in East Africa is to bang on a metal bucket and whistle loudly. When swarms afflict five countries and swell to the size of Moscow, more drastic measures are needed.

In Kenya, police facing the country’s largest outbreak in 70 years have fired machine guns and tear gas into swarms in an effort to prevent them from consuming fields. Ethiopia is spraying pesticide from small planes to displace hovering throngs, though swarms have forced passenger jets in the region to make emergency landings.

In Eritrea and Djibouti, teams in the hundreds are chasing swarms with hand-held pesticide pumps and truck-mounted sprayers.

The rising number of desert locusts presents an unprecedented threat to food security and livelihoods in the Horn of Africa, the United Nations Food and Agriculture Organization said on Wednesday.

Get fresh news and exclusive analysis on politics, policy, national security, regulation and more, delivered right to your inbox

“This has become a situation of international dimensions that threatens the food security of the entire subregion,” Qu Dongyu, director general of the FAO said last week.

Desert locusts—the most devastating of all locust species—can consume their weight in food each day. Swarms potentially containing hundreds of millions of insects each can travel over 90 miles a day; a swarm the size of Manhattan can consume as much food in a day as the population of the New York tri-state area, said FAO locust expert Keith Cressman. Some swarms are far bigger.

If the outbreak isn’t controlled and conditions remain favorable for breeding, it could reach 30 countries in Africa and Asia, the U.N. said.

“This is a more serious emergency than we had earlier anticipated,” said Guleid Artan, the climate prediction director at East Africa’s Intergovernmental Authority on Development. “More locust swarms are entering northern Kenya daily and at this rate they could soon spread into Uganda and South Sudan.”

Extreme weather is behind the infestation, according to the U.N. East Africa experienced abnormally heavy rains late last year, flooding regions that are normally semiarid. Such conditions are favorable for locust breeding, which can grow substantially if not disrupted—a challenge in cash-strapped countries contending with insurgencies and other security challenges. Continued breeding in some areas is already deepening the crisis.

Swarms entered Kenya in late December from Somalia, where security challenges had left a large breeding area uncontrolled. When the swarms crossed the border, relief officials said, residents in the Kenyan county of Wajir started shouting, whistling and drumming to scare the insects away.

The efforts forced the initial swarm to retreat. But a day later, larger swarms returned, clouding the sky. Police units fired tear gas and bullets but the locusts didn’t disperse. Locusts have continued to spread; this week, the swarms moved to around 90 miles east of the capital, Nairobi, alarming the region’s corn and fruit growers, local officials said.

The U.N. estimates that 23.6 million people in the region are already facing food shortages due to rains, insecurity and now locust infestation. Some 8.4 million people in Ethiopia alone may need food aid because of crop losses from the locusts, the U.N. warned.

Aerial spraying is the only effective method to reduce locust numbers, according to the U.N., which said it needed more than $70 million from donors to address the crisis.

Spraying, expensive and dangerous in areas where there are militants operating, has so far covered less than a third of affected areas, according to East Africa’s Intergovernmental Authority on Development.

In Ethiopia, Africa’s second-most populous nation, locusts have invaded around 700 square miles of cropland, pastures and forests, in the country’s largest infestation this century. Less than 10% of the affected area has been sprayed, according to FAO data. Spraying in grazing areas is particularly challenging as it can take days for herders to move their livestock out of the way.

Ethiopia and Kenya need at least two more spray planes, while no such control measures have been possible in war-afflicted Somalia.

The nexus of the locust breeding is around the Red Sea plains in the borderlands between Sudan and Eritrea.

If unchecked, the locust swarms could grow by 500 times by June, when drier weather is expected to slow breeding, according to the FAO.

Kenyan officials have attempted to play down the impact. The agriculture minister, Peter Munya, said this week that only five swarms remained and the government was in control of the situation.

Locust swarms move quickly, shifting location and shape, making infestations challenging to control.

For Kenya, sub-Saharan Africa’s second-largest exporter of fruits and vegetables after South Africa, the stakes are high. Effects from a 2018 drought followed by flooding last year slashed Kenya’s main grain harvest by around a third, pushing up food prices and stirring unrest in poorer pastoral communities. Economic growth slowed to 5.8% last year from 6.3% in 2018, weighed down in part by the decline in agricultural output.

A major locust outbreak in northern Africa between 2003 and 2005 cost nearly $600 million to control, including some $90 million in food aid distributed to affected nations, according to the U.N. Post-harvest losses topped an estimated $2.5 billion, the U.N. said.

“We need to deal with the locust invasion now,” said an FAO spokeswoman. “And also take forward-looking action to protect rural livelihoods and safeguard food security.”

Write to Nicholas Bariyo at nicholas.bariyo@wsj.com