He said Mr. Holt had “easily satisfied” the requirement of showing that the ban on beards burdened his religious practices. Justice Alito said a trial judge had been mistaken in saying it was enough to provide Mr. Holt with a prayer rug, the ability to correspond with a religious adviser, appropriate meals and the like.

Image Gregory H. Holt Credit Arkansas Department of Correction

Even so, prison officials said they had compelling reasons for the ban, the most important being combating contraband. Even short beards, one official said, can conceal “anything from razor blades to drugs to homemade darts.” Another said that SIM cards for cellphones can also be hidden in beards.

Justice Alito responded that the idea that security “would be seriously compromised by allowing an inmate to grow a half-inch beard is hard to take seriously.”

“An item of contraband would have to be very small indeed to be concealed by a half-inch beard,” he wrote, “and a prisoner seeking to hide an item in such a short beard would have to find a way to prevent the item from falling out.”

Arkansas prisons do not require “shaved heads or short crew cuts,” Justice Alito wrote, and so “it is hard to see why an inmate would seek to hide contraband in a half-inch beard rather than in the longer hair on his head.”

Justice Alito noted that a magistrate judge had observed Mr. Holt and said, “It’s almost preposterous to think that you could hide contraband in your beard.”

If officials remain fearful of contraband, Justice Alito said, they may search prisoners’ beards.

“The department already searches prisoners’ hair and clothing, and it presumably examines the quarter-inch beards of inmates with dermatological conditions,” he wrote, dismissing concerns “that requiring guards to search a prisoner’s beard would pose a risk to the physical safety of a guard if a razor or needle was concealed in the beard.”

That is true of other kinds of searches, Justice Alito wrote, adding that guards could also require that “the prisoner run a comb through his beard.”