Updated

A federal appeals court ruled in favor of a Texas prison inmate Monday, allowing him to wear a beard and a skullcap as required by his religious beliefs.

A three-judge 5th U.S. Circuit Court of Appeals in New Orleans unanimously upheld a lower-court ruling that David Rasheed Ali, 33, should be allowed to grow a 4-inch bear and wear a knit skullcap, called a kufi, as his faith demands. The court ruled in a 32-page opinion.

Ali is a Muslim inmate serving four concurrent 20-year prison sentences for arson, criminal mischief and aggravated robbery at the state’s Michael Unit in East Texas near Palestine.

The opinion written by Appeals Judge Edward Prado said that the Texas ban on inmates having 4-inch beards and religious headwear outside a cell or religious service violates a 2015 U.S. Supreme Court ruling in an Arkansas inmate's case.

Prado wrote that under the Texas Department of Criminal Justice’s procedures, officials require inmates with longer hair to shake it out with their fingers in case they are hiding contraband or tattoos. Prado wrote the same rules could apply to beards.

Texas officials had argued that its ban was needed for security purposes, that beards and caps could facilitate the smuggling of contraband and distort the identities of inmates and potential escapees.

“We are reviewing the opinion and have no further comment at this time, Texas prisons spokesman Jason Clark told the Austin American-Statesman Tuesday.

In the Arkansas case, the Supreme Court ruled that a Muslim inmate could maintain a half-inch beard because prison officials there could not substantiate its security claims. In the 5th Circuit Court opinion, Prado wrote that experts called by Texas to support its security claims were not credible and that beards and caps would still be subject to search.

According to the paper, the ruling affirms a 2014 judgment made by U.S. Magistrate Zack Hawthorn who ordered prison officials to allow Ali to grow a beard and wear a kufi in his unit.

The Associated Press contributed to this report.