OPINION OF THE COURT
Jones, J.Under the Constitution and statutes of the State of New York, it would have been a violation of the right of a Muslim inmate to free exercise of his religious beliefs, in *505the limited circumstances of this case, for him to have been subjected to a random pat frisk performed by a correction officer of the opposite sex. This intrusion on the prisoner’s religious beliefs would not have been justified here by the State’s interests in maintaining prison security or in providing equal opportunity for women to serve as prison guards. It was error, however, for the courts below to have ordered that references to the incident be expunged from the inmate’s institutional records.
On October 11,1982, petitioner, Edwin Rivera, who is a Muslim and is incarcerated at the Attica Correctional Facility, was moving in formation with his company heading for a movie. He and two or three other inmates were selected at random for a pat frisk. When a female correction officer, respondent M. Ricks, approached him to conduct the frisk, Rivera objected and asked that a male officer perform the search. According to Rivera, his objection was based on his religious belief, as embodied in the Holy Qu'ran, “that all believers should be modest of their person and they shouldn’t submit to contact or lustful * * * desires, towards the opposite sex or even with your own sex”. Rivera was advised to speak with a sergeant about his objection. Sergeant Wolf was summoned and, when informed of the situation, told Rivera to submit to the frisk or return to his cell. Rivera was then taken to his cell where he was locked in. About a half hour later, he was charged in a misbehavior report filed by Officer Ricks with refusal to obey a direct order, interference with an employee, and violation of search and frisk rules.
Rivera appeared before the institution’s Adjustment Committee on October 12, 1982 where he admitted refusing to permit the frisk. The committee imposed a penalty of seven days of continuous confinement to his cell and loss of 23 days of specified privileges.
By order to show cause dated November 30,1982, Rivera commenced this article 78 proceeding against the Superintendent of the Attica Correctional Facility, Correction Officer Ricks and Sergeant Wolf, seeking an order declaring that Directive 4910 of the Department of Correctional Services, which governs frisks of inmates, is unconstitu*506tional and expunging from his record the write-up of his refusal to submit to the frisk.
At a hearing held on February 9, 1983, Professor William L. Gohlman, a professor of Middle Eastern and Islamic History, testified that the Qu'ran forbids a Muslim from revealing his genitals to or having them touched by a member of the opposite sex other than his spouse. According to Gohlman, the Qu'ran is the “direct, literal word of God, is the foundation of all Islamic law and cannot be controverted in any way.” Gohlman testified that for a Muslim to have his body touched, even with clothing on, by a member of the opposite sex would be absolutely prohibited, shameful and a very great sin. He further indicated that this prohibition is listed in the Qu'ran among its major tenets and is “put on the same level as prayer, alms giving and the other pillars of Islam, the basis of the Islamic religion.”
Gohlman conceded that in an emergency these religious tenets may be waived if absolutely necessary, the principle being that if there is freedom to choose one must heed the prohibition but if one’s will is overcome failure to observe the prohibition is not condemned. As to the situation in which a female correction officer attempts a frisk of a male inmate, Gohlman testified that it would depend on the extent to which the prisoner is physically prevented from refusing and that the prisoner should resist to the point at which it would cause him more harm to resist than not to resist.
Abdul Mujahid Shakir, the Imam of the American Muslim Mission at Attica, testified that the Qu'ran forbids intimate physical contact between members of the opposite sex who are not married to each other. It was Shakir’s position that in a pat search the woman officer has to touch all areas of the body and would come into contact with the intimate parts, and that this would violate the Qu'ran’s admonition to guard one’s intimate parts, maintain one’s modesty, and refrain from physical contact with the opposite sex which may tend to bring about sexual arousal.
Brenda Valentine, a correction officer at Attica, testified that she had conducted over 30 pat frisks and that in performing them she doesn’t touch the genital area though *507she does put her hands in the vicinity. The search is conducted by patting the outer clothing over the entire length of the inmate’s torso, touching the skin only at the shirt sleeves and collar, and checking the seams and pockets of the prisoner’s clothing. She testified that there was always another officer present during these frisks though on perhaps three occasions in which she had performed them no male officer was present. When she had observed random pat frisks being conducted, 12 inmates were selected to be frisked by 12 guards of whom 8 were male officers.
Directive 4910 of the Department of Correctional Services (dated Jan. 20, 1981) was introduced in evidence at the hearing. On October 11,1982 section IV(D)(2)(b) of the directive provided that: “A Tat Frisk’ may be made on inmates to be interviewed by Departmental officials, the Board of Parole, or official visitors; entering the visiting room of a maximum or medium security facility; going to and returning from housing areas and/or outside work details; when the entire or individual area of the facility or living quarters is searched; or when there are reasonable grounds to believe an inmate is in possession of contraband.”1 A provision that a pat frisk “shall be conducted by an officer of the same sex as the inmate being frisked” had been deleted from the directive on June 1, 1981 after the Department promulgated Directive 2230 on May 18, 1981 which was intended to extend equal rights in employment to all employees regardless of sex.2 Section II of Directive 2230 provides, in pertinent part, that:
“1. All correction officers will perform the duties that are assigned to them, regardless of sex, provided however, that the following assignments will not be made to officers who are not of the same sex as the inmates:
“a. strip searches
“b. congregate shower facilities
*508* * *
“3. Pat frisks of inmates will be performed by officers regardless of sex.”
Supreme Court, in a memorandum and judgment dated April 5,1983, granted the petition. The court found that a pat frisk conducted by a female officer involves sufficient physical contact to violate a male Muslim’s religious beliefs which prohibit physical contact between the sexes outside of marriage. According to the court, these religious beliefs are protected by the free exercise provision of section 3 of article I of the New York State Constitution and by section 610 of the Correction Law which recognizes that prison inmates retain their rights to free exercise of religious beliefs. The court noted that these rights are subject to reasonable curtailment if necessary for proper discipline and management of the correctional facility.
After balancing the competing interests involved, Supreme Court concluded that where searches are carried out as a routine precaution or are conducted at random male correction officers could be used to pat frisk Muslims. Inasmuch as Directive 4910 had previously required that pat frisks be performed by an officer of the same sex as the inmate and still so mandates for more intrusive searches, the court found that the only security interest advanced in withdrawing this protection as to pat frisks is the avoidance of delay. This delay, according to the court, would be minimal because Muslim inmates are readily identifiable by the prayer caps which they are permitted to wear.
The court concluded that any interest a female employee may have in her job assignments would not dictate a contrary result. Having male officers available to search Muslim prisoners, the court reasoned, would serve a bona fide purpose of protecting the religious rights of inmates. Further, the requested relief would have only a very slight impact on the assignment of female officers because several officers usually accompany groups of inmates.
Accordingly, the court declared that the performance of a pat frisk of a male Muslim inmate by a female correction officer, in the circumstances of this case, violated religious rights guaranteed by the Correction Law and the New *509York Constitution. The court ordered that such a frisk be performed by an officer of the same sex as the Muslim prisoner in the absence of reasonable grounds to believe that the inmate possesses contraband or that there is an emergency situation. Inasmuch as the court concluded that it is not permissible to punish a prisoner for exercising a valid religious right, the court further ordered that any reference to the charges filed on October 11, 1982 or the disposition made the following day by the Adjustment Committee be expunged from petitioner’s institutional records.
On appeal by the Superintendent and the correction officers, the Appellate Division affirmed, with two Justices dissenting. The majority distinguished Madyun v Franzen (704 F2d 954 [7th Cir]), which held that a pat frisk of an Islamic male prisoner by a female prison guard did not violate the inmate’s rights under the free exercise clause of the Federal Constitution because such searches are justified by the important State interests of providing adequate prison security and equal opportunity for women to serve as prison guards. According to the Appellate Division, in New York section 3 of article I of our State Constitution and section 610 of the Correction Law evince a greater concern for religious freedom of inmates than may be found in other jurisdictions. Consequently, the court held that the inmate’s free exercise right had been violated under State law in the limited circumstances of this case.
The dissenters were of the view that there were no special circumstances to except this case from what they perceived to be the general rule that all inmates, even those with religious objections, are subject to frisk searches by correction officers of the opposite sex (citing Madyun v Franzen, 704 F2d 954, supra). According to the dissent, the mere presence of a male correction officer did not render this otherwise lawful search violative of New York law. Nor should the legality of such a search depend on whether the officer has reasonable cause to believe that the inmate possesses contraband or that emergency circumstances justify the frisk. The dissenters would have held that the State has a substantial interest in having its women guards frisk male inmates and that such frisk searches are an *510integral part of prison security and an important part of a prison guard’s duties.
The Superintendent and correction officers have appealed as of right to our court. We now modify the order appealed from.
Our analysis starts with the proposition that with the closing of the prison doors behind him an inmate loses, or must endure substantial limitations on, many rights and privileges he previously enjoyed, a status justified by the character of our penal system (Matter of Brown v McGinnis, 10 NY2d 531, 536; see Price v Johnston, 334 US 266, 285). Nevertheless, a prisoner does not lose all rights during incarceration but rather retains those rights that are not inconsistent with his status as an inmate or with the legitimate penological objectives of the prison institution (see Pell v Procunier, 417 US 817, 822). In the context of religious freedom, it is clear that the prisoner maintains the right to free exercise of religion under the first amendment of the Federal Constitution (LaReau v MacDougall, 473 F2d 974 [2d Cir], cert den 414 US 878; Sweet v South Carolina Dept. of Corrections, 529 F2d 854 [4th Cir]; Childs v Duckworth, 705 F2d 915 [7th Cir]; Teterud v Burns, 522 F2d 357 [8th Cir]; see Cruz v Beto, 405 US 319; Cooper v Pate, 378 US 546), although the Supreme Court of the United States has yet to delineate the breadth of this right.
Under New York law, section 3 of article I of our State Constitution provides that “[t]he free exercise and enjoyment of religious profession and worship, without discrimination or preference, shall forever be allowed in this state to ail mankind”. This free exercise right has expressly been extended to those incarcerated in New York correctional facilities by section 610 of the Correction Law.3 In so *511providing, the Legislature recognized the positive effect that religion can have in rehabilitating convicts and in shaping their behavior while in prison. These provisions of New York law manifest the importance which our State attaches to the free exercise of religious beliefs, a liberty interest which has been called a “preferred right” (Matter of Brown v McGinnis, 10 NY2d 531, 536, supra).
Notwithstanding the importance of this right, it does not prevent the imposition of reasonable restrictions by prison officials (Matter of Shahid v Coughlin, 83 AD2d 8, 11-12, affd on opn below 56 NY2d 987; Matter of Brown v McGinnis, 10 NY2d 531, 535-536, supra; Correction Law, § 610), but rather such restrictions must be weighed against the institutional needs and objectives being promoted (Matter of Shahid v Coughlin, 83 AD2d, p 11, supra; see Bell v Wolfish, 441 US 520, 546; Wolff u McDonnell, 418 US 539, 556). The nature of a correctional facility, where confinement and order are necessary, is such that inmates cannot be afforded free exercise rights as broad as those enjoyed outside the prison setting.
Supreme Court found that Rivera’s Muslim beliefs compelled him to avoid contact with members of the opposite sex outside of marriage. This view was supported by the testimony of Dr. Gohlman that the Qu'ran requires Muslims to avoid such physical contact, even when clothed, but that the “sin” of such contact might be forgiven if one’s will to prevent it is violated in an emergency. Further *512support for Rivera’s religious belief was provided by the testimony of Shakir. Nor did respondent ever challenge the sincerity or bona fides of petitioner’s religious convictions (cf. Matter of Holy Spirit Assn. u Tax Comm., 55 NY2d 512, 526). Inasmuch as the Appellate Division affirmed Supreme Court’s findings, these factual determinations are beyond the scope of our review. Supreme Court further found that, based on Officer Valentine’s description of the manner in which pat frisks are performed, a pat frisk by a female correction officer involves physical contact which is violative of the religious creed of a male Muslim inmate.4 This finding, too, having been affirmed at the Appellate Division, is not reviewable in our court, there being evidence for its support in the record.
The question thus becomes whether the impingement on Rivera’s religious convictions caused by a routine pat frisk conducted by a woman officer is outweighed by a legitimate institutional need or objective of the correctional facility. The Superintendent and the correction officers assert two interests which, they contend, justify application to Muslim inmates of their policy that pat frisks be performed by all officers without regard to the officer’s sex. They support this policy on the grounds that it is necessary to maintain prison security and that it provides equal opportunity for women to serve as correction officers.
With respect to the first asserted interest, it cannot be questioned that prison administrators have a substantial interest in maintaining security in their facilities. The extraordinary difficulties of managing prisons, in which the daily activities of a large number of inmates who have been confined due to their criminal, and often violent, conduct must be supervised, are such that the maintenance of order and discipline is a critical objective. Prison officials are charged with the responsibility, among other things, to secure their institutions against escape, to prevent the transfer or possession of contraband, and to protect the safety of inmates and prison employees. To carry out these *513formidable tasks in the volatile setting of our correctional institutions requires that prison officials be vested with broad discretion in their formulation of security-related policies.
In the limited circumstances of the present case, however, it has not been shown that legitimate security objectives are advanced by having female correction officers randomly pat frisk Muslim male inmates. When petitioner was approached by Officer Ricks there were other male officers in the vicinity who could have performed the search. Further, Officer Valentine testified that during random frisks she had observed that 12 inmates were searched by 12 guards, of whom 8 were male officers. Supreme Court found that, based on the Department of Correctional Services’ previous prohibition on pat frisks by officers of the opposite sex and its continued policy that more restrictive searches be performed by officers of the same sex as the inmates searched, the only security interest advanced in not providing such protection for pat frisks is the avoidance of the delay required to respond to a Muslim’s objection. The court concluded that such delay would be minimal inasmuch as Muslim inmates can easily be identified by the prayer caps which they are allowed to wear and thus officers can readily determine which inmates should be frisked by male guards. Accordingly, it has not been established that security interests call for the use of female prison guards to perform random pat frisks of male Muslim inmates in violation of the letters’ religious beliefs.
The argument that the policy of having officers perform pat frisks regardless of sex is justified by the State’s interest in affording women equal opportunity to serve as correction officers, important as that objective is, does not compel a different result on the facts of this particular case. The Governor has promulgated Executive Order No. 6 which establishes that it is the policy of the State “that equal opportunity be assured in the State’s personnel system and affirmative action provided in its administration”. The order requires each State agency or department to “develop a revised written affirmative action program, where necessary, including the development of specific *514goals and timetables for the prompt achievement of full and equal employment opportunity for minorities, women, disabled persons and Vietnam era veterans.” To implement this policy, the Commissioner of the Department of Correctional Services issued his own policy statement which condemns the lack of equal opportunity for all and “acknowledges and accepts [the Department’s] obligation to eliminate those forms of discrimination that exist within” the Department. According to the Superintendent and the correction officers, the Department’s amendment of Directive 4910, which had prohibited female prison guards from frisking male inmates, and its issuance of Directive 2230, which provides that pat frisks are to be performed by all officers regardless of their sex, are in furtherance of this policy.
The Department’s policy of providing equal opportunity in employment unquestionably promotes a salutary objective. We need not now decide, however, whether the State’s interest in this regard can outweigh an inmate’s right to free exercise of religion (compare Forts v Ward, 621 F2d 1210 [2d Cir]; Madyun v Franzen, 704 F2d 954 [7th Cir], supra; Smith v Fairman, 678 F2d 52 [7th Cir]; and Sterling v Cupp, 290 Ore 611). Nor need we consider whether limiting random pat frisks of Muslim inmates to officers of the same sex as the inmate searched to protect Muslim religious beliefs would be justified as a bona fide occupational prescription (see Dothard v Rawlinson, 433 US 321). In the present instance, two or three other inmates were selected for routine searches along with petitioner. Officer Ricks could have been assigned to frisk a non-Muslim prisoner while a male officer frisked petitioner. Any one correction officer does not have the absolute right to pat frisk any single inmate of his or her selection. Accommodating the religious beliefs of Muslim inmates in this instance could be attained with only a minimal impact on job assignments because, as Officer Valentine testified, routine frisks had been conducted on groups of 12 prisoners by 12 officers, 8 of whom were male. There is no proof in the record in this case that denial to Officer Ricks of the opportunity to conduct a pat frisk of Rivera frustrated the objectives of the equal opportunity policy. Thus, it has not *515been shown that the State’s interest in providing equal employment opportunity to women justified a pat frisk of Rivera by Officer Ricks.
Accordingly, we hold that, in the setting in which this frisk was to be made, for Officer Ricks to have conducted a routine pat frisk of Rivera would have violated his right to the free exercise of his religious beliefs guaranteed by section 3 of article I of the New York Constitution and section 610 of the Correction Law.
We turn now to consideration of the appropriate remedy to be fashioned in this case. As well as declaring that a pat frisk by Officer Ricks would have violated Rivera’s right under New York law to the free exercise of his religious beliefs and ordering that in similar circumstances such a search be performed by a guard of the same sex absent a reason to believe the inmate possesses contraband or other emergency circumstances, Supreme Court ordered that any reference to the charges and their disposition be expunged from Rivera’s records. This latter relief was inappropriate.
In view of the characteristics of the correctional system and the compelling interests of the State in the preservation of security and order within correctional facilities, the recognition and enforcement even of constitutional rights may have to await resolution in administrative or judicial proceedings; self-help by the inmate cannot be recognized as an acceptable remedy. There must, in most instances (including this case), be compliance with the orders of the correction personnel, or acceptance of the penalties properly applicable to noncompliance. The risks inescapably attendant on the refusal of an inmate to carry out even an illegal order of a correction officer are such as to require compliance at the time with the right of retrospective administrative or judicial determination as to the legality of the order.
As was noted in a similar context in Matter of Shahid v Coughlin (83 AD2d 8, 12, affd on opn below 56 NY2d 987, supra): “Inmates who object to a particular prison rule should obey the rule until such time as established procedures can effectuate a change. Any holding to the contrary would simply encourage inmates to break rules as a means *516of addressing their grievances and invite chaos.” The threat to prison security would be manifest were we to allow inmates to decide for themselves which orders to obey and which to ignore as violative of their rights and to act accordingly. In principle the legal situation is not unlike that in which an individual against whom an injunction has been granted must comply with the terms of the injunction or be liable for contempt for failure to do so, notwithstanding that the injunctive order is illegal. His remedy lies in judicial challenge to the injunction, not in personal refusal to obey its command. (United States v Mine Workers, 330 US 258, 293; City School Dist. v Schenectady Federation of Teachers, 49 AD2d 395, 397, mot for lv to app den 38 NY2d 820; cf. Matter of Balter v Regan, 63 NY2d 630, 631, cert den 469 US _, 53 USLW 3324.) Consequently, we cannot sanction petitioner’s refusal to submit to the frisk by expunging the incident from his files.5
Accordingly, the order of the Appellate Division appealed from should be modified, without costs, to eliminate the expunging of petitioner’s institutional record and, as so modified, affirmed.
. Section III(J)(2) of the directive defines a pat frisk as “a search of an inmate’s person and his clothes while the inmate is clothed, except that an inmate shall be required to remove coat, hat, and shoes. The search shall include searching into the inmate’s clothing.” Rivera makes no assertion that the pat frisk in this instance did not come within the scope of Directive 4910.
. The directive by its terms does not apply to the Bedford Hills Correctional Facility because that institution was the subject of the Second Circuit’s decision in Forts v Ward (621 F2d 1210) which recognized certain privacy rights of female inmates.
. Section 610 of the Correction Law provides as follows:
“1. All persons who may have been or may hereafter be committed to or taken charge of by any of the institutions mentioned in this section, are hereby declared to be and entitled to the free exercise and enjoyment of religious profession and worship, without discrimination or preference.
“2. This section shall be deemed to apply to every incorporated or unincorporated society for the reformation of its inmates, as well as houses of refuge, penitentiaries, protectories, reformatories or other correctional institutions, continuing to receive for its use, either public moneys, or a per capita sum from any municipality for the support of inmates.
“3. The rules and regulations established for the government of the institutions mentioned in this section shall recognize the right of the inmates to the free exercise of their religious belief, and to worship God according to the dictates of their consciences, *511including baptism by immersion, in accordance with the provisions of the constitution; and shall allow religious services on Sunday and for private ministration to the inmates in such manner as may best carry into effect the spirit and intent of this section and be consistent with the proper discipline and management of the institution; and the inmates of such institutions shall be allowed such religious services and spiritual advice and spiritual ministration from some recognized clergyman of the denomination or church which said inmates may respectively prefer or to which they may have belonged prior to their being confined in such institutions; but if any of such inmates shall be minors under the age of sixteen years, then such services, advice and spiritual ministration shall be allowed in accordance with the methods and rites of the particular denomination or church which the parents or guardians of such minors may select; such services to be held and such advice and ministration to be given within the buildings or grounds, whenever possible, where the inmates are required by law to be confined, in such manner and at such hours as will be in harmony, as aforesaid, with the discipline and the rules and regulations of the institution and secure to such inmates free exercise of their religious beliefs in accordance with the provisions of this section. In case of a violation of any of the provisions of this section any person feeling himself aggrieved thereby may institute proceedings in the supreme court of the district where such institution is situated, which is hereby authorized and empowered to enforce the provisions of this section.”
. Respondents’ contention that being pat frisked by a woman officer involves only a minimal intrusion on petitioner’s free exercise right is belied by Professor Gohlman’s testimony that such contact would be shameful and a very great sin and that the prohibition against this contact is on the same level as other major tenets of petitioner’s religion.
. Although respondents did not raise this issue in the courts below, a new argument may be raised for the first time in the Court of Appeals if it could not have been obviated or cured by factual showings or legal countersteps in the court of first instance (American Sugar Refining Co. v Waterfront Comm., 55 NY2d 11, 25, app dsmd sub nom. New York Shipping Assn. v Waterfront Comm., 458 US 1101; Telaro v Telara, 25 NY2d 433, 439; see Cohen and Karger, Powers of the New York Court of Appeals [rev ed], §§ 161-163).