We must decide whether the district court should have granted qualified immunity before trial to prison officials who implemented a policy permitting digital rectal probe searches on inmates before their entry into a secure area of the prison known as the Intensive Management Unit. The court relied heavily on our decision in Tribble v. Gardner, 860 F.2d 321 (9th Cir.1988), cert. denied, 490 U.S. 1075, 109 S.Ct. 2087, 104 L.Ed.2d 650 (1989), where we denied summary judgment on the basis of qualified immunity to the same prison officials.
It allowed this case to proceed to trial without ruling on the officials’ motion for summary judgment on the basis of qualified immunity. Later, the court erroneously bifurcated the qualified immunity issue from the trial and denied the officials qualified immunity as a matter of law when the *591jury concluded that the policy was not reasonably related to a legitimate penological purpose. We find that this was a misapplication of Tribble and hold that the prison officials are entitled to qualified immunity as a matter of law.
I
This case consolidates eight of the more than 100 cases filed by Washington State Penitentiary (WSP) prisoners who were subjected to digital rectal cavity searches. The general background of these cases was given in Tribble, 860 F.2d 321, and Wetmore v. Gardner, 735 F.Supp. 974 (E.D.Wash.1990).
In 1984, prison officials instituted a policy requiring that every inmate transferred to the Intensive Management Unit (IMU) would be subject to an involuntary digital rectal cavity search to detect contraband.1 An inmate was asked to submit first to a strip search. After that search, he was secured with leg irons, a chain around his waist and handcuffs. Four or five guards escorted him to a hospital examination room. The digital probe of the inmate’s rectal cavity occurred while he was still chained and in the presence of the search and escort squad. A member of the squad videotaped the search to ensure that procedures were properly followed and to monitor the inmate’s behavior. No contraband was ever found.
Terrence Wetmore, an inmate incarcerated at the WSP, brought this civil rights action alleging that he was deprived of his Fourth and Eighth Amendment rights when he was subjected to a digital rectal probe search on January 17, 1986, before his placement in the IMU. Wetmore testified that before the search, a guard told him, “Today, you meet Dr. Big Finger.” When the guards came to transfer him, he refused to submit to the standard strip search. The guards subdued him and, in the process, injured his ankle. Because of his injury, he was taken to a hospital x-ray room, rather than an exam room, where he underwent a digital rectal probe.
The jury returned a verdict against four of the five officials, awarding nominal damages of $1.00. The four officials found to be liable were administrative personnel who were instrumental in implementing the digital probe search policy. The fifth official, Nurse Zabor, who performed the search, was found not liable.
The court denied the officials’ motion for judgment notwithstanding the verdict or in the alternative for a new trial. The officials argue that the issue of whether they were entitled to qualified immunity should not have been bifurcated and that they are entitled to such immunity. They also attack jury instructions and challenge eviden-tiary rulings.
In seven cases tried after Wetmore, the court applied the doctrine of offensive collateral estoppel to deny the officials the opportunity to relitigate the constitutional claims or the qualified immunity defense. Six inmates were awarded damages; Hemphill received attorney’s fees. The officials in the case before us also appeal the court’s application of this doctrine.
II
We review de novo the district court’s denial of the defense of qualified immunity. Baker v. Racansky, 887 F.2d 183, 185 (9th Cir.1989).
Prison officials who have implemented a digital rectal probe policy are entitled to qualified immunity if, in light of the clearly established law at the time, a reasonable official could have believed that his conduct was lawful. See Anderson v. Creighton, 483 U.S. 635, 641, 107 S.Ct. *5923034, 3039-40, 97 L.Ed.2d 523 (1987). To determine whether this standard is satisfied, we recently established a two-part analysis: “1) Was the law governing the official’s conduct clearly established? 2) Under that law, could a reasonable officer have believed the conduct was lawful?” Act Up!/Portland v. Bagley, 988 F.2d 868, 871 (9th Cir.1993).
At the time of the Wetmore search, it was not clearly established that digital rectal probe searches without individualized suspicion of high security risk inmates violated constitutional rights. In fact, the case law available to the prison officials in 1986 tended to establish the opposite proposition. See Upton v. Thompson, 930 F.2d 1209, 1212 (7th Cir.1991) (a court must examine “closely analogous cases” decided before defendants’ challenged actions to determine whether the right was clearly established), cert. denied, —. U.S. -, 112 S.Ct. 1262, 117 L.Ed.2d 491 (1992).
When Wetmore was searched, the use of digital rectal searches without cause on difficult inmates was permissible and sanctioned by federal regulations. See 28 C.F.R. § 541.48(a) (1986) (digital rectal searches permissible on inmates upon entry to control unit). At the time, only one federal appellate court had considered the issue and it held that digital rectal searches were constitutional. Daughtery v. Harris, 476 F.2d 292 (10th Cir.) (upholding policy requiring a digital rectal examination before transferring an inmate out of prison to the custody of U.S. Marshals), cert. denied, 414 U.S. 872, 94 S.Ct. 112, 113, 38 L.Ed.2d 91 (1973). A state court considering the question reached the same conclusion. State v. Hartzog, 96 Wash.2d 383, 635 P.2d 694 (1981) (routine probe searches permitted on inmates before their appearance in state court).2 Other courts had considered the propriety of different body cavity searches, holding that the constitutionality of such searches depended on the circumstances. See United States v. Lilly, 576 F.2d 1240, 1244, 1246 (5th Cir.1978) (although need for body cavity searches served a legitimate penological purpose, because no notice of searches was given, seizure was unconstitutional). As the Lilly court noted, had there been a valid prison regulation dealing with random body cavity searches, the notice requirement might have been satisfied and the search constitutional.
In light of the information available to the officials at the time of the Wetmore search, the district court erred in allowing this case to proceed to trial without first considering whether reasonable officials could have believed that the policy regarding searches was constitutional.
As the Supreme Court recently emphasized in Hunter v. Bryant, — U.S.-, -, 112 S.Ct. 534, 536, 116 L.Ed.2d 589 (1991), it is important to resolve immunity questions at the earliest possible stage of litigation. In Bryant, the Court rejected the approach of routinely submitting the question of immunity to the jury, asserting that, ordinarily, immunity questions should be decided long before trial. Id., — U.S. at-, 112 S.Ct. at 537. The district court must determine whether officials acted reasonably under settled law in the circumstances, not whether another reasonable approach can be invented after the fact. Id.
The Court concluded by emphasizing the breadth of the qualified immunity doctrine. The Court said that it “ ‘gives ample room *593for mistaken judgments’ by protecting ‘all but the plainly incompetent or those who knowingly violate the law.’ ” Id. (quoting Malley v. Briggs, 475 U.S. 335, 343, 341, 106 S.Ct. 1092, 1097, 89 L.Ed.2d 271 (1986)).
If a reasonable official could have believed that his actions were lawful, summary judgment on the basis of qualified immunity is appropriate. See Act Up!/Portland, 988 F.2d at 872-73. This determination should have been made before the district court considered whether the policy was constitutional.3 See id. Only if there be a genuine issue of fact that would preclude a grant of summary judgment, should the court let the case to proceed to trial. Id. at 873.
Here, the district court allowed this case to proceed to trial without ruling on the officials’ summary judgment motion. The court probably relied on our Tribble decision to deny summary judgment. In Trib-ble, we held that the law was clearly established that a digital rectal probe search policy must be reasonably related to a legitimate penological purpose. 860 F.2d at 325. We agreed with the district court’s finding that Tribble, a WSP inmate, had produced sufficient evidence to raise a question of material fact regarding the purpose of the searches. Although we affirmed the court’s denial of defendants’ summary judgment motion, we rejected Tribble’s theory that the prison officials were automatically liable. We said the officials would still be entitled to qualified immunity “if the trier of fact finds that the searches are reasonably related to a legitimate penological goal or that the defendants reasonably could have believed that the searches were conducted to further such a purpose.” Id., 860 F.2d at 328.-Therefore, Tribble left open the question of the defendants’ reasonable belief. Yet evidence on this subject was presented at Wetmore’s trial. We may rely on the record before us in holding that the officials are entitled to qualified immunity as a matter of law.
We have already discussed the case law available to the officials at the time of the Wetmore search. In addition to that background, the officials testified at trial that they developed the policy for security purposes and that they researched the legality of digital rectal searches before implementing the policy. WSP Superintendent Lawrence Kincheloe testified that he discussed the subject with WSP correctional officers who had worked with segregation units and with the staff at the Federal Bureau of Prisons in Marion, Illinois. He testified that it was his understanding that digital rectal searches were performed at Marion at the time WSP implemented its search policy.
Both Kincheloe and Walter Kautzky, Deputy Secretary for the Washington Department of Corrections, testified that they relied on legal advice from the Washington Attorney General to support their conclusion that the use of x-rays, as an alternative to the digital searches, was not a viable option under Washington law. Kautz-ky testified that the Attorney General’s office closely monitored the Department of Corrections’ policy-making process and that the policy would not have gained approval if it violated state law. Kautzky also testified that in 1986 he was aware that one other prison conducted digital rectal searches without cause.
*594Wetmore’s testimony that he was not strip searched and that a guard made a crude comment to him is insufficient to undermine the officials’ assertion that they believed such searches were necessary to keep the IMU contraband-free or that the case law and advice on which they relied was faulty.
Because of the importance of deciding the qualified immunity issue at the earliest point possible, the district court should not have taken this case to judgment without first ruling on the qualified immunity question. Based on the information available to the officials at the time of Wetmore’s search, the district court should have found that reasonable officials could have believed their conduct was lawful.
Ill
Because we decide that the officials are entitled to qualified immunity as a matter of law, we need not reach the other issues presented by this appeal. The seven cases consolidated with Wetmore’s are reversed for the reasons stated in this opinion.
REVERSED.
. The IMU houses those inmates who present the greatest threat to the orderly and safe operation of the penitentiary. Its location outside the main institution and its special policies and procedures are designed to prevent the serious security breaches present in previous segregation units.
. Two district courts found that rectal probe searches were illegitimate where the institution offered no reason for their use. See Frazier v. Ward, 426 F.Supp. 1354, 1363-66 (N.D.N.Y.1977) (blanket rectal probe searches of high-risk prison inmates invalidated when prison security interests not seriously jeopardized and searches conducted in humiliating manner); Hodges v. Klein, 412 F.Supp. 896, 899 (D.N.J.1976) (absent showing of breach of security, anal inspection disallowed on prisoners transferring, under escort, from one segregated area of prison to another).
. Under Act Upl/Portland, we must first decide whether reasonable officials could have believed that the searches were constitutional. See id. at 872. If we find that the officials were reasonable in their belief, we need not decide whether the policy itself is constitutional. See id. Because we conclude that the officials’ belief was reasonable, we need not decide whether the search policy violated Wetmore’s Fourth and Eighth Amendment rights.