OPINION OF THE COURT
Stein, J.In this appeal, we are asked to determine whether a patient who is involuntarily committed under article 9 of the Mental Hygiene Law and is unlawfully held beyond the authorized retention period may seek a writ of habeas corpus under article 70 of the CPLR. We answer this question in the affirmative, concluding that Mental Hygiene Law § 33.15 is not the exclusive habeas corpus provision available to article 9 patients and does not govern habeas corpus proceedings for those patients whose detention is challenged for reasons other than the patient’s recovery.
L
As relevant here, Mental Hygiene Law article 9 governs the procedures and standards for the involuntary commitment of mentally ill persons who are in need of inpatient care and treatment but are unable to understand the necessity of such treatment. Pursuant to the Mental Hygiene Law, “[t]he director of a hospital may receive and retain therein as a patient any person alleged to be mentally ill and in need of involuntary care and treatment upon the certificates of two examining physicians, accompanied by an application for the admission of *127such person” executed by a qualified person {id. § 9.27 [a]; see id. § 9.27 [b] [1H11]).1 When a patient is involuntarily admitted, the facility may hold that person for a limited period of time; if further retention is necessary, the director of the facility must apply to the court for an order authorizing continued retention within 60 days of the admission {see id. § 9.33 [a]). Upon request, the patient is entitled to a hearing on the application for a retention order {see id.). Once an order retaining the patient for a specific duration has been obtained, if the director believes that it is necessary to retain the patient beyond that time, the director “shall . . . apply during the period of retention authorized by the last order of the court . . . for an order authorizing further continued retention of such patient” {id. § 9.33 [d] [emphasis added]). The patient is, again, entitled to appear before the court on such an application {see id.).
The Mental Hygiene Law presents several specific avenues for a patient to challenge his or her retention. For example, Mental Hygiene Law § 9.31 allows the patient to request a hearing prior to the expiration of the 60-day admission period {see id. § 9.31 [a]). Section 9.35 permits a patient to seek a rehearing and review of a court’s order of retention within 30 days of the making of such an order. Additionally, and central to the present dispute, Mental Hygiene Law § 33.15 provides that “[a] person retained by a facility ... is entitled to a writ of habeas corpus to question the cause and legality of detention upon proper application” {id. § 33.15 [a]). This section requires the court to “examine the facts concerning the person’s alleged mental disability and detention,” and the court may discharge the patient only “if it finds that he [or she] is not mentally disabled or . . .in need of further retention for in-patient care and treatment” {id. § 33.15 [b]).
More generally, article 70 of the CPLR governs special proceedings for a writ of habeas corpus, the historic common-law writ that protects individuals from unlawful restraint or imprisonment and provides a means for those illegally detained *128to obtain release (see People ex rel. Duryee v Duryee, 188 NY 440, 445 [1907]). CPLR 7001 provides that, “[e]xcept as otherwise prescribed by statute, the provisions of . . . article [70] are applicable to common [-] law or statutory writs of habeas corpus.” The CPLR does not specifically enumerate the circumstances in which a writ may be sought beyond providing that “[a] person illegally imprisoned or otherwise restrained in his [or her] liberty within the state, or one acting on his [or her] behalf . . . , may petition without notice for a writ of habeas corpus to inquire into the cause of such detention and for deliverance” (CPLR 7002 [a]). “If the person is illegally detained a final judgment shall be directed discharging him [or her] forthwith” (CPLR 7010 [a] [emphasis added]).
IL
In March 2012, Stephen S. was involuntarily admitted to Holliswood Hospital upon two medical certifications averring that, as a result of his paranoid delusions, Stephen S. was unable to care for himself and required mental health treatment. In May 2012, the Hospital applied to Supreme Court for authorization to continue his involuntary retention. In June 2012, Supreme Court granted the application upon the parties’ consent, extending his retention for a period not to exceed three months. The Hospital thereafter failed to apply for court authorization of its continued involuntary retention of Stephen S. on or before the expiration date of the existing order, as was required by Mental Hygiene Law § 9.33 (d).
In October 2012, Mental Hygiene Legal Service commenced this habeas corpus proceeding on behalf of Stephen S., seeking his immediate release from the Hospital on the ground that he was being illegally detained. In response, the Hospital applied for an order authorizing his continued involuntary retention for a period of six months pursuant to Mental Hygiene Law § 9.33. The Hospital conceded that it had erroneously retained Stephen S. without a court order for approximately six weeks, but it argued that, under Mental Hygiene Law § 33.15, he could not be released without a hearing and, then, only if the court found him to be mentally fit for discharge. Conversely, Stephen S. argued that he was entitled to immediate release upon a writ of habeas corpus under CPLR article 70.
Supreme Court granted the writ and directed the Hospital to discharge Stephen S., but stayed his discharge for five days in order to allow for appellate review. In directing the release of *129Stephen S., the court reasoned that holding a hearing on his mental status would be a “non-remedy” for the violation of his due process rights because such a hearing would have been held had the Hospital filed a timely retention application. In other words, the court postulated that, if it merely granted the Hospital such a hearing, the Hospital’s failure to follow the Mental Hygiene Law would have had no effect on whether it could retain him without his consent.
The Hospital appealed. The Appellate Division, Second Department, initially stayed enforcement of the judgment pending its determination of the appeal (2012 NY Slip Op 90691[U] [2d Dept 2012]) and, thereafter, reversed (117 AD3d 84 [2d Dept 2014]). The Appellate Division determined that, although the matter had been rendered moot by the discharge of Stephen S. during the pendency of the appeal, the mootness exception applied. Despite the Hospital’s failure to comply with the Mental Hygiene Law, the Appellate Division held that Stephen S. was not entitled to immediate release without a determination of his mental fitness, reasoning that the habeas corpus petition was governed by Mental Hygiene Law § 33.15, not CPLR article 70.
Stephen S. appealed pursuant to CPLR 5601 (b) (1), and we now reverse.2
III.
The Hospital argues that Mental Hygiene Law § 33.15 governs all habeas corpus proceedings brought by article 9 patients and, therefore, a patient is not entitled to release unless a determination is made that further involuntary treatment is unnecessary. The Hospital contends that section 33.15 should be construed as the exclusive habeas corpus provision available to article 9 patients because the more general CPLR article 70 habeas provisions must yield to the specific mandate of section 33.15. According to the Hospital, such an interpretation is consistent with principles of due process because involuntary commitment of an individual is lawful so long as the individual is in need of treatment — without regard to whether the procedures of the Mental Hygiene Law were followed.
*130We disagree on all counts. The construction of Mental Hygiene Law § 33.15 advanced by the Hospital and our dissenting colleague abrogates the common-law writ of habeas corpus for mentally ill patients and is not supported by our case law, the rules of statutory construction, or principles of due process. As explained below, section 33.15 does not supplant the common-law writ of habeas corpus available through CPLR article 70.
Although article 70 governs the procedure of the common-law writ of habeas corpus, “[r]elief from illegal imprisonment by means of this remedial writ is not the creature of any statute” (People ex rel. Tweed v Liscomb, 60 NY 559, 565 [1875]). As we have long emphasized, “the right to invoke habeas corpus, ‘the historic writ of liberty’, ‘the greatest of all writs’,” is a “primary and fundamental” one (People v Schildhaus, 8 NY2d 33, 36 [1960]; see US Const, art I, § 9; NY Const, art I, § 4). Due to its constitutional roots, “[t]his writ cannot be abrogated, or its efficiency curtailed, by legislative action,” except in certain emergency situations (People ex rel. Tweed, 60 NY at 566; see Hoff v State of New York, 279 NY 490, 492 [1939]; People ex rel. Sabatino v Jennings, 246 NY 258, 261 [1927]). Moreover, statutes pertaining to the writ of habeas corpus must be “construed in favor of, and not against, the liberty of the subject and the citizen” (People ex rel. Tweed, 60 NY at 569; see People ex rel. Perkins v Moss, 187 NY 410, 418 [1907]).
CPLR 7001 provides that article 70 applies to common-law and statutory writs of habeas corpus “[e]xcept as otherwise prescribed by statute.” However, nothing in the plain language of Mental Hygiene Law § 33.15 purports to limit the availability of the common-law writ in Mental Hygiene Law proceedings. Rather, section 33.15 enhances the efficacy of the writ of habeas corpus, as our case law dictates, and thereby ensures that patients are not committed and retained without due process of law. That is, Mental Hygiene Law § 33.15 allows patients to seek a writ of habeas corpus when they are being held pursuant to a court order but, nevertheless, believe they have sufficiently recovered from their mental illness so that their continued retention is unwarranted; in such cases, determining the legality of their retention would require an inquiry into their mental state. On the other hand, patients whose detention is otherwise unauthorized may proceed under the habeas corpus provisions of CPLR article 70 since the legal*131ity of their detention can be determined on the basis of, for example, whether the appropriate procedures have been followed, without the need for a hearing into their mental state.
This interpretation — which reads section 33.15 and article 70 consistently with one another — accords with the rules of statutory construction (see generally Matter of Dutchess County Dept. of Social Servs. v Day, 96 NY2d 149, 153 [2001] [“Statutes which relate to the same subject matter must be construed together unless a contrary legislative intent is expressed”]; People v Epton, 19 NY2d 496, 505 [1967]). Most significantly, it preserves the availability of the great writ of habeas corpus (see People ex rel. Perkins, 187 NY at 418; People ex rel. Tweed, 60 NY at 569; see also Schildhaus, 8 NY2d at 36 [“the right to invoke habeas corpus . . . is so primary and fundamental that it must take precedence over considerations of procedural orderliness and conformity”]). By contrast, the Hospital’s reading of section 33.15 would effectively eliminate the availability of the writ for patients wishing to challenge the procedural methods by which they have been involuntarily retained and to obtain release from an unlawful detention. Such diminution of the great writ is impermissible (see People ex rel. Sabatino, 246 NY at 261; People ex rel. Tweed, 60 NY at 566; see also Mental Hygiene Law § 33.01; People ex rel. Thorpe v Von Holden, 63 NY2d 546, 554 [1984] [habeas corpus proceeding available to criminal offenders found not guilty by reason of mental disease or defect and committed to the custody of the Commissioner of Mental Health where statutory time schedule was not followed]).
This is not the first time we have sanctioned a patient’s use of a writ of habeas corpus to obtain release where a facility failed to follow the appropriate procedures to lawfully retain the individual (see e.g. People ex rel. Jacobs v Director of Gowanda State Hosp., 14 NY2d 663, 665 [1964], affg 19 AD2d 858, 858 [4th Dept 1963]; People ex rel. Granskofski v Whitehead, 8 NY2d 962, 963 [1960], affg 10 AD2d 801, 801 [4th Dept 1960]). Indeed, the express extension of the writ to involuntarily committed patients who have become mentally fit for discharge — rather than curtailment of the writ — has long been considered the purpose of section 33.15 and its predecessor provisions (see Matter of Coates, 9 NY2d 242, 246 [1961] [noting that a patient may pursue discharge under Mental Hygiene Law habeas provision “at any time” upon ground that “the patient is sane”]; People ex rel. Sabatino, 246 NY at 261 *132[indicating that the question under section 93 of the Insanity Law, from which section 33.15 of the Mental Hygiene Law is derived, “is whether one lawfully committed to an asylum has thereafter become sane”]; People ex rel. Ledwith v Board of Trustees of Bellevue & Allied Hosps., 238 NY 403, 408 [1924] [where hospital failed to timely follow procedures, the patient “was entitled to the writ of habeas corpus, either under section 93 of the Insanity Law or, if that be inapplicable, under article 77 of the Civil Practice Act relating to habeas corpus”]; Matter of Andrews, 126 App Div 794, 799-800 [1st Dept 1908] [“In addition to the remedy for a discharge on writ of habeas corpus in case the detention is without lawful process, the Legislature . . . expressly extended the writ of habeas corpus to cases of lawful commitments of persons as insane who have subsequently, while held under such lawful commitments, recovered their reason”]). As these cases make clear, section 33.15 does not govern habeas proceedings where the right to release is premised upon unlawful process.
The dissent suggests that “there is no rational reason to determine that Mental Hygiene Law § 33.15 does not apply’ in habeas proceedings alleging an unauthorized retention (dissenting op at 136). Yet, in addition to contravening the purpose of the historic writ, ratification of the Hospital’s interpretation of section 33.15 would undermine the procedural due process protections guaranteed by the various provisions of the Mental Hygiene Law requiring notice and regular judicial review in connection with a patient’s commitment (see generally Epton, 19 NY2d at 505). It is beyond dispute that “[t]he state ‘has authority under its police power to protect the community from the dangerous tendencies of some who are mentally ill,’ ” and that it “may rely on its parens patriae power to provide care to its citizens who are unable to care for themselves because of mental illness” (Matter of K.L., 1 NY3d 362, 370 [2004], quoting Addington v Texas, 441 US 418, 426 [1979]). Nevertheless, it has long been recognized that involuntary civil commitment involves a “ ‘massive curtailment of liberty’ ” (Vitek v Jones, 445 US 480, 491 [1980], quoting Humphrey v Cady, 405 US 504, 509 [1972]) and, “therefore[,] [it] cannot permissibly be accomplished without due process of law” (Rodriguez v City of New York, 72 F3d 1051, 1061 [2d Cir 1995]; see Savastano v Nürnberg, 77 NY2d 300, 307 [1990]). Thus, contrary to the Hospital’s contention, a patient may be involuntarily committed only where the standards for commitment and the proce*133dures set forth in the Mental Hygiene Law — which satisfy the demands of due process — are met (see Matter of K.L., 1 NY3d at 371; Project Release v Prevost, 722 F2d 960, 971 [2d Cir 1983]; see generally Savastano, 77 NY2d at 305-309 [recognizing that the Mental Hygiene Law procedures and regulations provide a “network of procedural safeguards” for “the due process rights of those involuntary patients”]). This is not to say that every violation of the Mental Hygiene Law amounts to a due process violation or will entitle a patient to a writ of habeas corpus but, “[w]ithout a court order of continued retention [in accordance with the Mental Hygiene Law], or the consent of the patient, the hospital must release the patient” (Project Release, 722 F2d at 967; see People ex rel. Tweed, 60 NY at 569 [“The law is no respecter of persons, and suffers no (person) . . . to be deprived of his (or her) liberty, except ‘by due process of law;’ and the writ of habeas corpus is as available . . . (to) he (or she) whom the popular voice would condemn” (emphasis omitted)]).
The dissent’s statement that “patients will still receive the procedural protections required by due process” if Mental Hygiene Law § 33.15 applies in a case such as this overlooks the fact that patients who are seeking a common-law writ under CPLR article 70 are alleging that they have already been deprived of due process by virtue of a violation of the procedural protections of the Mental Hygiene Law (dissenting op at 137). Thus, a conclusion that section 33.15, with its required hearing to determine the patient’s mental status, is the exclusive habeas corpus avenue available to article 9 patients would permit the flagrant disregard — either deliberately or through laxity — of the due process protections provided throughout the Mental Hygiene Law, and there would be no effective remedy available to a patient for a facility’s failure to comply with even the most basic of the statutory procedural requirements. Indeed, implicit in the dissent’s assertion that application of section 33.15 does not violate the due process rights of a patient who establishes that his or her detention is unauthorized by the court or the Mental Hygiene Law is the dissent’s conclusion that an article 9 patient has no enforceable due process rights so long as there exists proof that he or she could benefit from further treatment, regardless of whether that proof is presented six weeks or a matter of years after expiration of the court order authorizing the patient’s retention. Such a view of section 33.15 would essentially nullify the *134procedural due process protections contained in other provisions of the Mental Hygiene Law, which are already defined by reference to the rights and interests at stake (see generally Savastano, 77 NY2d at 307). Moreover, under the dissent’s reading, by failing to seek continued retention under section 9.33, thereby prompting the patient to seek a writ of habeas corpus, in cases such as this — where the patient’s application is based on the facility’s inaction — the Hospital would be able to shift the burden of proof to the patient to demonstrate his or her fitness in order to obtain release pursuant to section 33.15 (see Matter of Mental Hygiene Legal Servs. ex rel. James U. v Rhodes, 195 AD2d 160, 162 [3d Dept 1994]; Matter of Winslow v O’Neill, 153 AD2d 563, 564 [2d Dept 1989]). We cannot countenance, and the legislature surely did not intend, an interpretation of section 33.15 that would render meaningless such significant protections as are provided in Mental Hygiene Law article 9.
In sum, we declare that Mental Hygiene Law § 33.15 does not preclude use of the writ of habeas corpus under CPLR article 70. Rather, Mental Hygiene Law § 33.15 merely clarifies that an article 9 patient is entitled to bring a habeas proceeding where the commitment is authorized, but the patient believes that he or she has sufficiently recovered to be released. If a facility is of the opinion that a patient requires further treatment notwithstanding having been granted a writ of habeas pursuant to CPLR article 70 following an illegal detention, it is incumbent upon the facility to commence a new article 9 proceeding in compliance with the strictures of the Mental Hygiene Law (compare People ex rel. Thorpe, 63 NY2d at 555). The Hospital’s remaining arguments are unavailing. Accordingly, the order of the Appellate Division should be reversed, without costs, the habeas corpus proceeding converted into a declaratory judgment action, and judgment granted in accordance with this opinion.
. Mental Hygiene Law § 9.39 sets forth an alternative procedure, to be used in emergency situations in which a person’s alleged mental illness “is likely to result in serious harm” to that person or another and immediate observation and treatment is appropriate (Mental Hygiene Law § 9.39 [a]). If retention beyond a specified time frame is required, the procedures governing admission and commitment pursuant to that section converge with those governing admission upon medical certification under section 9.33 (see id. § 9.39 [b]).
. In light of the Hospital’s discharge of Stephen S., we convert the proceeding to a declaratory judgment action (see People ex rel. McManus v Horn, 18 NY3d 660, 666 [2012]; Mental Hygiene Legal Servs. v Ford, 92 NY2d 500, 505 [1998]).