Mb. Chief Justice Warren
delivered the opinion of the Court.
We granted certiorari in this case to consider the constitutional validity of the statutory procedure under which petitioner was committed to a mental institution at the expiration of his criminal sentence in a state prison.
Petitioner, Johnnie K. Baxstrom, was convicted of second degree assault in April 1959 and was sentenced to a term of two and one-half to three years in a New York prison. On June 1, 1961, he was certified as insane by a prison physician. He was then transferred from prison to Dannemora State Hospital, an institution under the jurisdiction and control of the New York Department of Correction and used for the purpose of confining and caring for male- prisoners declared mentally ill while serving a criminal sentence. In November 1961, the director of Dannemora filed a petition in the Surrogate’s Court of Clinton County stating that Baxstrom’s penal sentence was about to terminate and requesting that he be civilly committed pursuant to § 384 of the New York Correction Law.
On December 6, 1961, a proceeding was held in the Surrogate’s chambers. Medical certificates were submitted by the State which stated that, in the opinion of two of its examining physicians, Baxstrom was still mentally ill and in need of hospital and institutional care. Respondent, then assistant director at Danne-mora, testified that in his opinion Baxstrom was still mentally ill. Baxstrom, appearing alone, was accorded a brief opportunity to ask questions. Respondent and the Surrogate both stated that they had no objection to his being transferred from Dannemora to a civil hospital under the jurisdiction of the Department of Mental Hygiene. But the Surrogate pointed out that he had no jurisdiction to determine that question — that under § 384 the decision was entirely up to the Department of Mental Hygiene. The Surrogate then signed a certificate which indicated he was satisfied that Baxstrom “may require mental care and treatment” in an institution for the mentally ill. The Department of Mental Hygiene had already determined ex parte that Baxstrom was not suitable for care in a civil hospital. Thus, on December 18, 1961, the date upon which Baxstrom’s penal sentence expired, custody over him shifted from the Department of Correction to the Department of Mental Hygiene, but he was retained at Dannemora and has remained there to this date.
Thereafter, Baxstrom sought a writ of habeas corpus in a state court. An examination by an independent psychiatrist was ordered and a hearing was held at which the examining psychiatrist testified that, in his opinion, Baxstrom was still mentally ill. The writ was dismissed. In 1963, Baxstrom applied again for a writ of habeas corpus, alleging that his constitutional rights had been violated and that he was then sane, or if insane, he should be transferred to a civil mental hospital. Due to his indigence and his incarceration in Dannemora, Baxstrom could not produce psychiatric testimony to disprove the testimony adduced at the prior hearing. The writ was therefore dismissed. Baxstrom’s alternative request for transfer to a civil mental hospital was again denied as being beyond the power of the court despite a statement by the State’s attorney that he wished that Baxstrom would be transferred to a civil mental hospital. On appeal to the Appellate Division, Third Department, the dismissal of the writ was affirmed without opinion. 21 App. Div. 2d 754. A motion for leave to appeal to the Court of Appeals was denied. 14 N. Y. 2d 490. We granted certiorari. 381 U. S. 949.
We hold that petitioner was denied equal protection of the laws by the statutory procedure under which a person may be civilly committed at the expiration of his penal sentence without the jury review available to all other persons civilly committed in New York. Petitioner was further denied equal protection of the laws by his civil commitment to an institution maintained by the Department of Correction beyond the expiration of his prison term without a judicial determination that he is dangerously mentally ill such as that afforded to all so committed except those, like Baxstrom, nearing the expiration of a penal sentence.
Section 384 of the New York Correction Law prescribes the procedure for civil commitment upon the expiration of the prison term of a mentally ill person confined in Dannemora. Similar procedures are prescribed for civil commitment of all other allegedly mentally ill persons. N. Y. Mental Hygiene Law §§ 70, 72. All persons civilly committed, however, other than those committed at the expiration of a penal term, are expressly granted the right to de novo review by jury trial of the question of their sanity under § 74 of the Mental Hygiene Law. Under this procedure any person dissatisfied with an order certifying him as mentally ill may demand full review by a jury of the prior determination as to his competency. If the jury returns a verdict that the person is sane, he must be immediately discharged. It follows that the State, having made this substantial review proceeding generally available on this issue, may not, consistent with the Equal Protection Clause of the Fourteenth Amendment, arbitrarily withhold it from some.
The director contends that the State has created a reasonable classification differentiating the civilly insane from the “criminally insane,” which he defines as those with dangerous or criminal propensities. Equal protection does not require that all persons be dealt with, identically, but it does require that a distinction made have some relevance to the purpose for which the classification is made. Walters v. City of St. Louis, 347 U. S. 231, 237. Classification of mentally ill persons as either insane or dangerously insane of course may be a reasonable distinction for purposes of determining the type of custodial or medical care to be given, but it has no relevance whatever in the context of the opportunity to show whether a person is mentally ill at all. For purposes of granting judicial review before a jury of the question whether a person is mentally ill and in need of institutionalization, there is no conceivable basis for distinguishing the commitment of a person who is nearing the end of a penal term from all other civil commitments.
The statutory procedure provided in § 384 of the New York Correction Law denied Baxstrom the equal protection of the laws in another respect as well. Under § 384 the judge need only satisfy himself that the person “may require care and treatment in an institution for the mentally ill.” Having made such a finding, the decision whether to commit that person to a hospital maintained by the Department of Correction or to a civil hospital is completely in the hands of administrative officials. Except for persons committed to Dannemora upon expiration of sentence under § 384, all others civilly committed to hospitals maintained by the Department of Correction are committed only after judicial proceedings have been held in which it is determined that the person is so dangerously mentally ill that his presence in a civil hospital is dangerous to the safety of other patients or employees, or to the community.
This statutory classification cannot be justified by the contention that Dannemora is substantially similar to other mental hospitals in the State and that commitment to one hospital or another is simply an administrative matter affecting no fundamental rights. The parties have described various characteristics of Dannemora to show its similarities and dissimilarities to civil hospitals in New York. As striking as the dissimilarities are, we need not make any factual determination as to the nature of Dannemora; the New York State Legislature has already made that determination. By statute, the hospital is under the jurisdiction of the Department of Correction and is used for the purpose of confining and caring for insane prisoners and persons, like Baxstrom, committed at the expiration of a penal term. N. Y. Correction Law § 375. Civil mental hospitals in New York, on the other hand, are under the jurisdiction and control of the Department of Mental Hygiene. Certain privileges of patients at Dannemora are restricted by statute. N. Y. Correction Law § 388. Moreover, as has been noted, specialized statutory procedures are prescribed for commitment to hospitals under the jurisdiction of the Department of Correction. While we may assume that transfer among like mental hospitals is a purely administrative function, where, as here, the State has created functionally distinct institutions, classification of patients for involuntary commitment to one of these institutions may not be wholly arbitrary.
The director argues that it is reasonable to classify persons in Baxstrom’s class together with those found to be dangerously insane since such persons are not only insane but have proven criminal tendencies as shown by their past criminal records. He points to decisions of the New York Court of Appeals supporting this view. People ex rel. Kamisaroff v. Johnston, 13 N. Y. 2d 66, 192 N. E. 2d 11; People ex rel. Brunson v. Johnston, 15 N. Y. 2d 647, 204 N. E. 2d 200.
We find this contention untenable. Where the State has provided for a judicial proceeding to determine the dangerous propensities of all others civilly committed to an institution of the Department of Correction, it may not deny this right to a person in Baxstrom’s position solely on the ground that he was nearing the expiration of a prison term. It may or may not be that Baxstrom is presently mentally ill and such a danger to others that the strict security of a Department of Correction hospital is warranted. All others receive a judicial hearing on this issue. Equal protection demands that Baxstrom receive the same.
The capriciousness of the classification employed by the State is thrown sharply into focus by the fact that the full benefit of a judicial hearing to determine dangerous tendencies is withheld only in the case of civil commitment of one awaiting expiration of penal sentence. A person with a past criminal record is presently entitled to a hearing on the question whether he is dangerously mentally ill so long as he is not in prison at the time civil commitment proceedings are instituted. Given this distinction, all semblance of rationality of the classification, purportedly based upon criminal propensities, disappears.
In order to accord to petitioner the equal protection of the laws, he was and is entitled to a review of the determination as to his sanity in conformity with proceedings granted all others civilly committed under § 74 of the New York Mental Hygiene Law. He is also entitled to a hearing under the procedure granted all others by § 85 of the New York Mental Hygiene Law to determine whether he is so dangerously mentally ill that he must remain in a hospital maintained by the Department of Correction. The judgment of the Appellate Division of the Supreme Court, in the Third Judicial Department of New York is reversed and the case is remanded to that court for further proceedings not inconsistent with this opinion.
It is so ordered.
Mr. Justice Black concurs in the result.
The State apparently permits counsel to be retained in such proceedings where the person can afford to hire his own attorney despite the fact that § 384 makes no provision for counsel to be present. See 1961 Op. N. Y. Atty. Gen. 180, 181. Baxstrom is indigent, however, and had no counsel at this hearing.
As it appeared when applied to petitioner in 1961, N. Y. Correction Law § 384 provided in part:
“1. Within thirty days prior to the expiration of the term of a prisoner confined in the Dannemora state hospital, when in the opinion of the director such prisoner continues insane, the director shall apply to a judge of a court of record for the certification of such person as provided in the mental hygiene law for the certification of a person not in confinement on a criminal charge. The court in which such proceedings are instituted shall if satisfied that such person may require care and treatment in an institution for the mentally ill, issue an order directing that such person be committed to the custody of the commissioner of mental hygiene to be placed in an appropriate state institution of the department of mental hygiene or of the department of correction as may be designated for the custody of such person by agreement between the heads of the two departments.”
In this case, the administrative decision to retain Baxstrom in Dannemora was made before any hearing was afforded to Baxstrom and was made despite the otherwise unanimous conclusion by testifying psychiatrists, including an independent examining psychiatrist and respondent himself, that there was no reason why Baxstrom could not be transferred to a civil institution. The following is a portion of the transcript of the hearing before the Surrogate:
“The Court: (Addressing Dr. Herold) Have you any objection if this man is transferred to a civil hospital if the Department of Mental Hygiene so decrees?
“Dr. Herold: None whatever.
“The Court: And I, Sir, agree with you. I have no objection to his transfer if the Department of Mental Hygiene so finds.
“I hope that you will be transferred to a civil hospital.
“Good luck.”
And at the first habeas corpus hearing:
“Q, Do you feel, Doctor, from your examination and examining the records of this man, he needs additional care? Is that correct?
“A. [Dr. Kerr] Yes, sir. May I say something at this point, sir?
“Q. Surely.
“A. Since Mr. Baxstrom’s sentence has actually expired, sir, I would like to say that in my opinion there is no reason why he could not be treated in a civil mental hospital. I would simply like to say that for the record, sir.
“The Court: All right.”
N. Y. Mental Hygiene Law §§ 85,135. See also N. Y. Code Crim. Proc. §§ 662-b (3)(b), 872 (l)(b), as amended, N. Y. Laws 1965, c. 540, §§ 1, 2. Former § 412 of Correction Law, permitting commitment to Matteawan State Hospital of any patient who had previously been sentenced to a term of imprisonment, without the benefit of the proceeding accorded others under § 85 of the Mental Hygiene Law, was held unconstitutional as a denial of equal protection in United States ex rel. Carroll v. McNeill, 294 F. 2d 117 (C. A. 2d Cir. 1961), probable jurisdiction noted, 368 U. S. 951, vacated and dismissed as moot', 369 U. S. 149, and was repealed by N. Y. Laws 1965, e. 524. Even that provision required a showing that the person still manifested criminal tendencies.
In oral argument, counsel for respondent suggested that the determination by the Department of Mental Hygiene to retain a person in Dannemora must be based not only on his past criminal record, but also on evidence that he is currently dangerous. Far from supporting the validity of the procedure, this only serves to further accent the arbitrary nature of the classification. Under this procedure, all civil commitments to an institution under the control of the Department of Correction require a determination that the person is presently dangerous; all persons so committed are entitled to a judicial proceeding to determine this fact except those awaiting expiration of sentence. Their fate is decided by unreviewable determinations of the Department of Mental Hygiene.