Mr. Justice Stewart
delivered the opinion of the Court.
When a member of the armed forces has applied for a discharge as a conscientious objector and has exhausted all avenues of administrative relief, it is now settled that he may seek habeas corpus relief in a federal district court on the ground that the denial of his application had no basis in fact. The question in this case is whether the district court must stay its hand when court-martial proceedings are pending against the serviceman.
The petitioner, Joseph Parisi, was inducted into the Army as a draftee in August 1968. Nine months later he applied for a discharge as a conscientious objector, claiming that earlier doubts about military service had crystallized into a firm conviction that any form of military activity conflicted irreconcilably with his religious beliefs. He was interviewed by the base chaplain, the base psychiatrist, and a special hearing officer. They all attested to the petitioner’s sincerity and to the religious content of his professed beliefs. In addition, the commanding general of the petitioner’s Army training center and the commander of the Army hospital recommended that the petitioner be discharged as a conscientious objector. His immediate commanding officer, an Army captain, disagreed, recommending disapproval of the application on the ground that the petitioner’s beliefs were based on essentially political, sociological, or philosophical views, or on a merely personal moral code.
In November 1969, the Department of the Army denied the petitioner conscientious objector status, on the grounds that his professed beliefs had become fixed prior to entering the service and that his opposition to war was not truly based upon his religious beliefs. On November 24, 1969, the petitioner applied to the Army Board for Correction of Military Records (hereafter sometimes ABCMR) for administrative review of that determination.
Four days later the petitioner commenced the present habeas corpus proceeding in the United States District Court for the Northern District of California, claiming that the Army’s denial of his conscientious objector application was without basis in fact. He sought discharge from the Army and requested a preliminary injunction to prevent his transfer out of the jurisdiction of the District Court and to prohibit further training preparatory to being transferred to Vietnam. The District Court declined at that time to consider the merits of the habeas corpus petition, but it retained jurisdiction pending a decision by the ABCMR, and in the meantime enjoined Army authorities from requiring the petitioner to participate in activity or training beyond his current noncombatant duties.
Shortly thereafter the petitioner received orders to report to Fort Lewis, Washington, for deployment to Vietnam, where he was to perform noncombatant duties similar to those that had been assigned to him in this country. He sought a stay of this redeployment order pending appeal of the denial of habeas corpus, but his application was denied by the Court of Appeals, on the condition that the Army would produce him if the appeal should result in his favor. A similar stay application was subsequently denied by Mr. Justice Douglas as Ninth Circuit Justice, Parisi v. Davidson, 396 U. S. 1233. The petitioner then reported to Fort Lewis. He refused, however, to obey a military order to board a plane for Vietnam. As a result, he was charged with violating Art. 90 of the Uniform Code of Military Justice, 10 U. S. C. § 890, and, on April 8, 1970, a court-martial convicted him of that military offense.
While the court-martial charges were pending, the Army Board for Correction of Military Records notified the petitioner that it had rejected his application for relief from the Army’s denial of his conscientious objector application. The District Court then ordered the Army to show cause why the pending writ of habeas corpus should not issue. On the Government’s motion, the District Court, on March 31, 1970, entered an order deferring consideration of the habeas corpus petition until final determination of the criminal charge then pending in the military court system. The Court of Appeals for the Ninth Circuit affirmed this order, concluding that “habeas proceedings were properly stayed pending the final conclusion of Parisi’s military trial and his appeals therefrom,” 435 F. 2d 299, 302. We granted certiorari, 402 U. S. 942.
In affirming the stay of the petitioner’s federal habeas corpus proceeding until completion of the military courts’ action, the Court of Appeals relied on the related doctrines of exhaustion of alternative remedies and comity between the federal civilian courts and the military system of justice. We hold today that neither of these doctrines required a stay of the habeas corpus proceedings in this case.
With respect to available administrative remedies, there can be no doubt that the petitioner has fully met the demands of the doctrine of exhaustion — a doctrine that must be applied in each case with an “understanding of its purposes and of the particular administrative scheme involved.” McKart v. United States, 395 U. S. 185, 193. The basic purpose of the exhaustion doctrine is to allow an administrative agency to perform functions within its special competence — to make a factual record, to apply its expertise, and to correct its own errors so as to moot judicial controversies. Id., at 194-195; McGee v. United States, 402 U. S. 479, 485; K. Davis, Administrative Law Treatise § 20.01 etseq. (Supp. 1970).
In this case the petitioner fully complied with Army Regulation 635-20, which dictates the procedures to be followed by a serviceman seeking classification as a conscientious objector on the basis of beliefs that develop after induction. Moreover, following a rule of the Ninth Circuit then in effect, he went further and appealed to the Army Board for Correction of Military Records. The procedures and corrective opportunities of the military administrative apparatus had thus been wholly utilized at the time the District Court entered its order deferring consideration of the petitioner’s habeas corpus application.
It is clear, therefore, that, if the court-martial charge had not intervened, the District Court would have been wrong in not proceeding to an expeditious consideration of the merits of the petitioner’s claim. For the writ of habeas corpus has long been recognized as the appropriate remedy for servicemen who claim to be unlawfully retained in the armed forces. See, e. g., Eagles v. Samuels, 329 U. S. 304, 312; Oestereich v. Selective Service Board, 393 U. S. 233, 235; Schlanger v. Seamans, 401 U. S. 487, 489. And, as stated at the outset, that writ is available to consider the plea of an in-service applicant for discharge as a conscientious objector who claims that exhaustion of military administrative procedures has led only to a factually baseless denial of his application. In re Kelly, 401 F. 2d 211 (CA5); Hammond v. Lenfest, 398 F. 2d 705 (CA2).
But since a court-martial charge was pending against the petitioner when he sought habeas corpus in March 1970, the respondents submit that the Court of Appeals was correct in holding that the District Court must await the final outcome of those charges in the military judicial system before it may consider the merits of the petitioner’s habeas corpus claim. Although this argument, too, is framed in terms of “exhaustion,” it may more accurately be understood as based upon the appropriate demands of comity between two separate judicial systems. Requiring tile District Court to defer to the military courts in these circumstances serves the interests of comity, the respondents argue, by aiding the military judiciary in its task of maintaining order and discipline in the armed services and by eliminating “needless friction” between the federal civilian and military judicial systems. The respondents note that the military'constitutes a “specialized community governed by a separate discipline from that of the civilian,” Orloff v. Willoughby, 345 U. S. 83, 94; Gusik v. Schilder, 340 U. S. 128, and that in recognition of the special nature of the military community, Congress has created an autonomous military judicial system, pursuant to Art. I, § 8, of the Constitution. They further point out that civilian courts, out of respect for the separation-of-powers doctrine and for the needs of the military, have rightly been reluctant to interfere with military judicial proceedings.
But the issue in this case does not concern a federal district court’s direct intervention in a case arising in the military court system. Cf. Gusik v. Schilder, supra; Noyd v. Bond, 395 U. S. 683. The petitioner’s application for an administrative discharge — upon which the habeas corpus petition was based — antedated and was independent of the military criminal proceedings.
The question here, therefore, is whether a federal court should postpone adjudication of an independent civil lawsuit clearly within its original jurisdiction. Under accepted principles of comity, the court should stay its hand only if the relief the petitioner seeks — discharge as a conscientious objector — would also be available to him with reasonable promptness and certainty through the machinery of the military judicial system in its processing of the court-martial charge. Griffin v. County School Board of Prince Edward County, 377 U. S. 218, 229; Davis v. Mann, 377 U. S. 678, 690-691; Lucas v. Forty-Fourth General Assembly of Colorado, 377 U. S. 713, 716-717. For the reasons that follow, we are not persuaded that such relief would be even potentially available, much less that it would be either prompt or certain.
Courts-martial are not convened to review and rectify administrative denials of conscientious objector claims or to release conscientious objectors from military service. They are convened to adjudicate charges of criminal violations of military law. It is true that the Court of Military Appeals has held that a soldier charged in a court-martial with refusal to obey a lawful order may, in certain limited circumstances, defend upon the ground that the order was not lawful because he had wrongfully been denied an administrative discharge as a conscientious objector. United States v. Noyd, 18 U. S. C. M. A. 483, 40 C. M. R. 195. The scope of the Noyd doctrine is narrow, United States v. Wilson, 19 U. S. C. M. A. 100, 41 C. M. R. 100, and its present vitality not wholly clear, United States v. Stewart, 20 U. S. C. M. A. 272, 43 C. M. R. 112. A Noyd defense, therefore, would be available, even arguably, only in an extremely limited category of court-martial proceedings. But even though we proceed on the assumption that Noyd offered this petitioner a potential affirmative defense to the court-martial charge brought against him, the fact remains that the Noyd doctrine offers, at best, no more than a defense to a criminal charge. Like any other legal or factual defense, it would, if successfully asserted at trial or on appeal, entitle the defendant to only an acquittal — not to the discharge from military service that he seeks in the habeas corpus proceeding.
The respondents acknowledge, as they must, the limited function of a Noyd defense in the trial and appeal of the court-martial proceeding itself. But they suggest that, if the military courts should eventually acquit the petitioner on the ground of his Noyd defense, then the petitioner may have “an available remedy by way of habeas corpus in the Court of Military Appeals.” In support of this suggestion, the respondents point to the All Writs Act, 28 U. S. C. § 1651 (a), and to cases in which the Court of Military Appeals has exercised power under that Act to order servicemen released from military imprisonment pending appeals of their court-martial convictions. See Noyd v. Bond, 395 U. S., at 695; Levy v. Resor, 17 U. S. C. M. A. 135, 37 C. M. R. 399; United States v. Jennings, 19 U. S. C. M. A. 88, 41 C. M. R. 88; Johnson v. United States, 19 U. S. C. M. A. 407, 42 C. M. R. 9.
But the All Writs Act only empowers courts to “issue all writs necessary or appropriate in aid of their respective jurisdictions . . . ,” and the jurisdiction of the Court of Military Appeals is limited by the Uniform Code of Military Justice to considering appeals from court-martial convictions. 10 U. S. C. § 867; United States v. Snyder, 18 U. S. C. M. A. 480, 40 C. M. R. 192. That court has been given no “jurisdiction” to consider a serviceman’s claim for discharge from the military as a conscientious objector.
Whether this conceptual difficulty might somehow be surmounted is a question for the Court of Military Appeals itself ultimately to decide. See United States v. Bevilacqua, 18 U. S. C. M. A. 10, 12, 39 C. M. R. 10, 12. But the short answer to the respondents’ suggestion in this case is the respondents’ own concession that that court has, to date, never so much as intimated that it has power to issue a writ of habeas corpus granting separation from military service to a conscientious objector. We conclude here, therefore, as in Noyd v. Bond, supra, at 698 n. 11, that the petitioner cannot “properly be required to exhaust a remedy which may not exist.” Accordingly, we reverse the judgment of the Court of Appeals and remand the case to the District Court with directions to give expeditious consideration to the merits of the petitioner’s habeas corpus application.
In holding as we do today that the pendency of court-martial proceedings must not delay a federal district court’s prompt determination of the conscientious objector claim of a serviceman who has exhausted all administrative remedies, we no more than recognize the historic respect in this Nation for valid conscientious objection to military service. See 50 U. S. C. App. § 456 (j); United States v. Seeger, 380 U. S. 163. As the Defense Department itself has recognized, “the Congress . . . has deemed it more essential to respect a man’s religious beliefs than to force him to serve in the Armed Forces.” Department of Defense Directive No. 1300.6 (May 10, 1968).
But our decision today should not be understood as impinging upon the basic principles of comity that must prevail between civilian courts and the military judicial system. See, e. g., Noyd v. Bond, 395 U. S. 683; Burns v. Wilson, 346 U. S. 137; Orloft v. Willoughby, 345 U. S. 83; Gusik v. Schilder, 340 U. S. 128. Accordingly, a federal district court, even though upholding the merits of the conscientious objector claim of a serviceman against whom court-martial charges are pending, should give careful consideration to the appropriate demands of comity in effectuating its habeas corpus decree.
The judgment is reversed.
Mr. Justice Powell and Mr. Justice Rehnquist took no part in the consideration or decision of this case.
At the time of oral argument of the present case, an appeal from this conviction was pending in a court of military review.
The right of a person in the armed forces to be classified as a conscientious objector after induction is bottomed on Department of Defense Directive No. 1300.6 (May 10, 1968), issued by the Secretary of Defense pursuant to his authority under 10 U. S. C. § 133. The purpose of the directive is to provide “uniform procedures for the utilization of conscientious objectors in the Armed Forces and consideration of requests for discharge on the grounds of conscientious objection.” Army Regulation 635-20 was issued to effectuate the broader policies announced in DOD Directive No. 1300.6.
Under the rule of Craycroft v. Ferrall, 408 F. 2d 587 (CA9 1969), the petitioner was required to appeal the Department of the Army’s decision to the civilian Army Board for Correction of Military Records in order to exhaust military administrative remedies and have access to federal court. Current governmental policy rejects Craycroft. Compliance with Army Regulation 635-20, not perfection of an ABCMR appeal, marks the point when military administrative procedures have been exhausted. Department of Justice Memo. No. 652 (Oct. 23, 1969). In Craycroft v. Ferrall, 397 U. S. 335, this Court vacated the judgment of the Ninth Circuit that the petitioner there had to appeal to the Board for the Correction of Naval Records before proceeding in federal court. But our decision was announced on March 30, 1970, more than four months after the present petitioner had appealed to the ABCMR.
In 1946, Congress enacted legislation empowering the service secretaries, acting through boards of civilian officers of their respective departments, to alter military records when necessary to prevent injustice. Legislative Reorganization Act of 1946, § 207, 60 Stat. 837, as amended by 70A Stat. 116, 10 U. S. C. § 1552 (1952 ed., Supp. IV). Pursuant to this legislation, each service established a board for the correction of military records whose function is, on application by a serviceman, to review the military record and intervene where necessary to correct error or remove injustice. 10 U. S. C. § 1552 (a).
The Department of Justice, in consultation with the Department of Defense, has accepted the holdings of the Kelly and Hammond cases. Department of Justice Memo. No. 652 (Oct. 23, 1969). See United States ex rel. Brooks v. Clifford, 409 F. 2d 700, 701 (CA4). Compare Noyd v. McNamara, 378 F. 2d 538 (CA10), with Polsky v. Wetherill, 403 U. S. 916, vacating judgment in 438 F. 2d 132 (CA10).
The respondents do not contend that the military courts have a special competence in determining if a conscientious objector application has been denied without basis in fact. As they acknowledge in their brief:
“Plainly, judicial review of the factual basis for the Army’s denial of petitioner’s conscientious objector claim does not require an interpretation of ‘extremely technical provisions of the Uniform Code [of Military Justice] which have no analogs in civilian jurisprudence,’ ” quoting Noyd v. Bond, 395 U. S. 683, 696.
Thus,, it is not contended that exhaustion of military court remedies — like exhaustion of military administrative remedies- — -is required by the principles announced in McKart v. United States, 395 U. S. 185, and McGee v. United States, 402 U. S. 479.
The concept of “exhaustion” in the context of the demands of comity between different judicial systems is closely analogous to the doctrine of abstention. For a discussion of the exhaustion and abstention doctrines in the federal-state context, see generally C. Wright, Handbook of the Law of Federal Courts 186-188, 196— 208 (2d ed. 1970).
Barker, Military Law — A Separate System of Jurisprudence, 36 U. Cin. L. Rev. 223 (1967); Warren, The Bill of Rights and the Military, 37 N. Y. U. L. Rev. 181 (1962). Military courts are legislative courts; their jurisdiction is independent of Art. Ill judicial power. Following World War II, Congress, in an attempt to reform and modernize the system of military law, created the Uniform Code of Military Justice, Act of May 5, 1950, c. 169, 64 Stat. 107. In 1968, the Code was amended by the Military Justice Act, 10 U. S. C. § 819, to improve court-martial and review procedures.
See Hammond v. Lenfest, 398 F. 2d 705, 710 (CA2 1968):
“Judicial hesitancy when faced with matters touching on military affairs is hardly surprising in view of the doctrine of separation of powers and the responsibility for national defense which the Constitution . . . places upon the Congress and the President. Moreover, the ever-present and urgent need for discipline in the armed services would alone explain the relative freedom of the military from judicial supervision.”
Army Regulation 635-20 provides that
“individuals who have submitted formal applications [for conscientious objector' status] . . . will be retained in their units and assigned duties providing the minimum practicable conflict with their asserted beliefs pending a final decision on their applications.” Noyd involved an Air Force officer who, after being denied conscientious objector status, refused to obey an order to instruct student pilots to fly a fighter plane used in Vietnam. Noyd’s commanding officer had refrained from ordering the accused to give such instruction until the application had been processed and denied. As the Court of Military Appeals said:
“The validity of the order [to instruct students], therefore, depended upon the validity of the Secretary’s decision [rejecting the conscientious objector application] ... If the Secretary’s decision was illegal, the order it generated was also illegal.” United States v. Noyd, 18 U. S. C. M. A. 483, 492, 40 C. M. R. 195, 204.
The petitioner did, in fact, interpose a Noyd defense at his court-martial trial, and it was rejected upon the military judge’s finding that “the ruling of the Secretary of the Army was not arbitrary, capricious, unreasonable, or an abusive [sic] discretion.”
We have been referred to no reported military court decision (including Noyd itself) that has yet acquitted a defendant upon the basis of a Noyd defense.
If the military courts should ultimately acquit the petitioner on grounds other than wrongful denial of his conscientious objector application, the respondents acknowledge that he could not seek habeas corpus in the military judicial system. In this event, therefore, the petitioner could clearly not obtain the relief that he seeks in the military court system.
This result is not inconsistent with the need to maintain order and discipline in the military and to avoid needless friction between the federal civilian and military judicial systems. If the Noyd defense is available and if the order that the petitioner disobeyed was unlawful if his conscientious objector claim is valid, then allowing him to proceed in federal district court as soon as military administrative remedies have been exhausted does not affect military-discipline. For if the conscientious objector claim is valid, the Army can have no interest in punishing him for disobedience of an unlawful order. If the conscientious objector claim is invalid, then the Army can, of course, prosecute the petitioner for his alleged disobedience of a lawful order.
Correlatively, if the charges in military court would be unaffected by the validity of the conscientious objector claim, both the petitioner’s habeas corpus action and the criminal trial in military court could proceed concurrently. See n. 15, infra. Needless to say, the question whether wrongful denial of conscientious objector status may be raised as a defense against various types of military charges must remain with the military courts, as they exercise their special function of administering military law.
See generally Report of the National Advisory Commission on Selective Service, In Pursuit of Equity: Who Serves When Not All Serve? 48-51 (1967); Selective Service System Monograph No. 11, Conscientious Objection (1950); Russell, Development of Conscientious Objector Recognition in the United States, 20 Geo. Wash. L. Rev. 409 (1952); Comment, God, the Army, and Judicial Review: The In-Service Conscientious Objector, 56 Calif. L. Rev. 379 (1968).
In the present case the respondents acknowledge that if the administrative denial of the petitioner’s conscientious objector claim had no basis in fact, then the court-martial charge against him is invalid. It follows that, if he should prevail in the habeas corpus proceeding, he is entitled to his immediate release from the military. At the other end of the spectrum is the hypothetical case of a court-martial charge that has no real connection with the conscientious objector claim — e. g., a charge of stealing a fellow soldier’s watch. In such a case, a district court, even though upholding the serviceman’s conscientious objector claim, might condition its order of discharge upon the completion of the court-martial proceedings and service of any lawful sentence imposed.