U.S. Army Sgt. Bowe Bergdahl deserted his post in Afghanistan in 2009 — there isn’t much doubt about that.

But the charge of desertion isn’t the reason he faces life imprisonment in his court-martial, announced Monday by the commanding officer at Fort Bragg, in North Carolina. Under the Uniform Code of Military Justice, the maximum punishment for desertion is five years. The potential life sentence comes from a now-obscure charge with origins in the articles of war enacted by the Continental Congress on Sept. 20, 1776: the charge of misbehavior before the enemy.

What, exactly, is this crime of misbehavior — and should it be applied to Bergdahl?

EditorialEditorial: Obama's first duty was to bring POW home

The story begins before the creation of the United States, with the early history of formal military regulations issued by the British crown for its soldiers.

Known as “articles of war,” the British regulations of 1762 stated that “whatsoever Officer or Soldier shall misbehave himself before the Enemy, or shamefully abandon any Post committed to his Charge, or shall speak Words inducing others to do the like, shall suffer Death.”

When the U.S. declared independence from Britain and the Revolutionary War began, Congress needed regulations of its own in a hurry. It therefore did what most new governments do: It copied and pasted from the British model.

advertisement | advertise on newsday

Today’s UCMJ Article 99, “Misbehavior before the enemy,” is the direct descendant of that provision, which makes it a crime for any member of the armed forces “before or in the presence of the enemy” to run away, abandon any place he or she has a “duty to defend,” commit “cowardly conduct,” or perform a number of other wrongful acts.

As late as World War II, the charge was apparently used frequently against combat soldiers who fled or otherwise displayed cowardice. In the long war that began on Sept. 11, 2001, desertion charges have been frequent, but the misbehavior charge has been extremely rare, used in only a handful of instances.

There’s something positively archaic about criminalizing fear, as the brilliant (and brilliantly quirky) Bill Miller of the University of Michigan Law School noted in 2000 in one of the very few contemporary academic articles about the misbehavior crime: “Making cowardice a capital offense strikes us as a kind of barbaric survival from a rougher age.”

We no longer think that pure fear in the face of combat should be harshly punished.

What’s more, today’s warfare is increasingly far away from the style that lasted through World War II and beyond, in which large numbers of troops had to move forward in unison with little or no covering fire.

Sign up for The Point

Go inside New York politics.

Under those circumstances, one soldier’s panicked flight could be infectious, spreading to other soldiers and thwarting a charge. That danger gave particularly strong reason to punish the misbehavior of fleeing before the enemy. Arguably, it’s less of a concern today, which may help explain the declining use of the charge.

But there’s a plausible reason to keep the charge on the books and even use it: the fact that the alternative desertion charge carries only a five-year penalty. Some misconduct seems so serious that conviction for desertion isn’t a strong enough moral condemnation.

In the eyes of many current and former U.S. military personnel, Bergdahl’s abandonment of his post, with the consequent dangerous search and eventual trading of important Taliban figures for his return, seems more morally blameworthy than simple desertion.

We don’t yet know all of Bergdahl’s motives. But his interview in the first installment of the “Serial” podcast already shows that he intended to create a “crisis” when he deserted. By his own account, he wasn’t acting out of fear, but out of a desire to draw attention to himself and to what he considered problems in his chain of command.

Filtering out political bias and the desire to embarrass the president who traded to get Bergdahl back, it’s still possible to understand the depth of the moral condemnation of Bergdahl’s unilateral act.

advertisement | advertise on newsday

The chain of command exists for a reason, and lives are saved or lost depending on whether it’s respected. This almost certainly explains why a general officer would decide to charge Bergdahl with misbehavior, even though independent military lawyers recommended lesser charges.

But Bergdahl’s own story, provided it’s true, also gives a plausible reason he should be acquitted of the misbehavior charge. By his account, he didn’t “shamefully” abandon or “surrender” in the face of an enemy attack, nor did he commit “cowardly conduct.” He deserted in a kind of fantasy haze of self-gratification, imagining himself, he said, as Jason Bourne.

Article 99 could be interpreted loosely to cover Bergdahl’s conduct. He did, after all, “run away” in some sense. But Article 99 is supposed to cover something more than mere desertion.

On its face, it applies to desertion for specified bad motives, especially cowardice. And Bergdahl’s motives, while foolish and even delusional, weren’t precisely the motives that the misbehavior crime is supposed to cover.

My bet is that Bergdahl won’t be convicted of the misbehavior charge, or that a military appeals court would overturn such a conviction.

advertisement | advertise on newsday

Meanwhile, the charge itself coveys the depth of the Army’s moral condemnation of his dangerous conduct.

Noah Feldman, a Bloomberg View columnist, is a professor of constitutional and international law at Harvard.