The police protect the public. The military protects the republic. In an age of terrorism, their jobs necessarily overlap, especially in large cities. But some lines between police officers and soldiers ought to remain distinct, and President Obama took an essential step this week toward reining in the counterproductive militarization of police departments that has occurred since the attacks of Sept. 11.

Last summer, Americans got an eye-opening glimpse of what can go wrong when local police departments made injudicious use of surplus military supplies. In the aftermath of the police shooting of Michael Brown in Ferguson, Mo., armored convoys with officers wearing military fatigues and wielding military rifles — and occasionally pointing them at peaceful protesters — made their town look like a war zone.

No citizens were shot, thankfully. But the inept response made the tense situation in Ferguson far worse. Many Americans were outraged, and elected officials in both political parties expressed concern. It was obvious the White House needed to clamp down on deliveries of military supplies and ensure that police departments receiving them be trained to use them properly.

But because almost nothing in Washington happens without the appointment of a commission, it took the president nine months to issue the executive order.

Better late than never. Crossed off the Army-surplus distribution list now are tanklike vehicles, grenade launchers, bayonets, camouflage uniforms, and — were these really included to begin with? — armored aircraft and ships. Departments will have to justify the need for other kinds of equipment, including explosives and mine-resistant ambush protected, or MRAP, vehicles. The bar ought to be set high.

Just as important, equipment will be distributed with new training requirements. Helping local police departments prevent and prepare for terrorist activity and attacks remains an urgent national challenge, but there are better ways to go about it — including by absorbing more of the costs that a few big-city police departments (such as New York, Chicago and Los Angeles) spend on counterterrorism. The federal government should also devote more funding to technologies that can alert the authorities to possible terrorist activity, from cameras that can detect suspicious actions (such as someone abandoning a suitcase on a street corner) to sensors that detect chemical weapons.

What doesn't help is to arm police officers like soldiers, then leave it to them to figure out how to proceed.

FROM AN EDITORIAL ON BLOOMBERG VIEW