
507 Pa. 360 (1985)
490 A.2d 402
The COUNTY OF ALLEGHENY and the Prison Board of Allegheny County, Appellants,
v.
The COMMONWEALTH of Pennsylvania; the Commonwealth of Pennsylvania, Bureau of Correction; Glen R. Jeffes, Commissioner, Bureau of Correction; Erskind Deramus, Deputy Commissioner, Bureau of Correction; and the Pennsylvania Board of Probation and Parole, Fred W. Jacobs, Chairman, Appellees.
The COUNTY OF ALLEGHENY and the Prison Board of Allegheny County, Appellants,
v.
The COMMONWEALTH of Pennsylvania; the Commonwealth of Pennsylvania, Bureau of Correction; Glen R. Jeffes, Commissioner, Bureau of Correction; Erskind Deramus, Deputy Commissioner, Bureau of Correction; and the Pennsylvania Board of Probation and Parole, Fred W. Jacobs, Chairman, Appellees.
Supreme Court of Pennsylvania.
Argued January 24, 1985.
Decided March 29, 1985.
*361 *362 *363 *364 *365 *366 *367 James H. McLean, Dennis R. Biondo (County Solicitor Offc.), Pittsburgh, for appellants.
Thomas F. Halloran, Francis R. Filipi, Deputy Attys. Gen., Harrisburg, for appellees.
Before NIX, C.J., and LARSEN, FLAHERTY, McDERMOTT, HUTCHINSON, ZAPPALA and PAPADAKOS, JJ.

OPINION
NIX, Chief Justice.
These are consolidated appeals from orders of the Commonwealth Court refusing to enter a preliminary mandatory injunction requiring the Bureau of Corrections (hereinafter *368 "Bureau")[1] and the Board of Probation and Parole (hereinafter "Board") to permit transfer of certain inmates then housed in the Allegheny County Jail (hereinafter "Jail") to appropriate state facilities and the sustaining of preliminary objections in the nature of a demurrer to an amended complaint filed by the County of Allegheny and its Prison Board (hereinafter collectively referred to as "County"). We are hearing these matters as a direct appeal pursuant to 42 Pa.C.S. § 723(a), 42 Pa.C.S. § 5105 and Rule of Appellate Procedure 311(a)(4).[2] Because of the increasing frequency of prison overcrowding and its impact upon the security and the safety of the citizens in those communities where these facilities are situated, we will overlook some of the glaring pleading deficiencies in the County's amended complaint and reach an issue which is of significant public importance. The issue involved is whether mandamus is an appropriate remedy to compel State agencies to assist political subdivisions in meeting the problems of prison overcrowding where the resources provided to the political subdivision by the State are demonstrably inadequate to meet the crisis. We conclude that it is an arbitrary exercise of discretion for a State agency charged with responsibility for the operation and maintenance of the various State correctional facilities to deny assistance to a political subdivision where it is demonstrated that the political subdivision has not been provided adequate resources to maintain its detention facilities in accordance with constitutional *369 standards and adequate security cannot be maintained. Moreover, where a crisis situation exists the political subdivision has a right to demand that prisoners who are committed to the custody of a State agency and temporarily placed in county facilities be transferred to appropriate State facilities in order to relieve overcrowding.

I.
The instant controversy is the by-product of continuing litigation in the federal courts concerning living conditions in the Jail. In 1978 inmates of the Jail brought a class action pursuant to 42 U.S.C. § 1983 challenging the constitutionality of the conditions under which they were confined. The United States District Court for the Western District of Pennsylvania, after a six-week trial, held that a number of those conditions were unconstitutional and appointed a master to make a report and recommendations. Owens-El v. Robinson, 442 F.Supp. 1368 (W.D.Pa.1978). The master's recommendations were subsequently adopted, 457 F.Supp. 984 (W.D.Pa.1978), and the County defendants did not appeal. An appeal by the inmates, however, led to a second trial on the adequacy of psychiatric care at the Jail. Inmates of Allegheny County Jail v. Pierce, 612 F.2d 754 (3d Cir.1979), on remand, 487 F.Supp. 638 (W.D.Pa.1980).
At the time of the District Court's initial ruling, overcrowding in the Jail was not found to be a problem. Owens-El v. Robinson, supra at 1376. By July of 1983, however, the Jail's population had increased by more than half, prompting the inmates to seek additional relief. On May 25, 1983, the District Court found the Jail to be unconstitutionally overcrowded and ordered a step-by-step reduction of the prison population. By January 1, 1984, there were to be no more than five hundred (500) male and thirty (30) female inmates housed in the Jail. Inmates of Allegheny County v. Wecht, 565 F.Supp. 1278 (W.D.Pa. 1983).
The County was initially able to comply with the population reduction scheme but, in August and September of *370 1983, the County moved for relief from the District Court's May 25 order, citing difficulty in relocating inmates to achieve the required population caps. On October 20, 1983, after a hearing on the County's motions, the District Court rejected the County's requests and ordered the Director and Warden of the Jail to release on their own recognizance prisoners held in default of the lowest amount of bail until the population limits mandated by the May 25 order were met.
On December 28, 1983, the County filed a complaint in mandamus and equity in the Commonwealth Court against the Bureau, its Commissioner and Deputy Commissioner, and the Board and its Chairman, following the Deputy Commissioner's refusal to authorize the transfer of seventy-six (76) specified inmates to state facilities. Shortly thereafter the District Court held a status conference. The court acknowledged the following actions by the County:
The County and the Prison Board have undertaken extensive efforts to reduce the population at the Jail and secure alternative housing for inmates in order to comply with the above-mentioned federal Order including:
a) Authorized the renovation of the County-owned Jones Law Building in Pittsburgh into an approximately 300 bed jail with completion for 1985;
b) Authorized the construction of a twenty-five bed group home for females in the Oakland section of Pittsburgh; this is due for completion of construction in the Spring of 1984;
c) Contracted with several non-profit agencies in the Pittsburgh area to provide temporary housing for non-violent inmates;
d) Contacted all municipalities in Allegheny County with police lock-ups with a view toward renting cells on a space available basis for persons convicted of driving while intoxicated;
e) Contacted all 24 counties in the Western Pennsylvania area and contracted with those counties with available *371 space for housing inmates from Allegheny County on a space available basis. Currently, there are 44 males and 14 females housed in those other counties and no additional space is available.
___ F.Supp. ___ (W.D.Pa.1984).
Expressing dissatisfaction with the prisoner release program and stressing the preferability of interim housing facilities, however, the court ordered that, after February 15, 1984, a sanction of Five Thousand Dollars ($5,000) would be imposed for each prisoner so released. That order was stayed pending the County's appeal to the Third Circuit Court of Appeals.
In the interim, on January 26, 1984, the County had filed in its action pending in the Commonwealth Court a motion for preliminary injunction, a motion for leave to file an amended complaint, and an amended complaint. The motion for leave was granted on February 14, 1984. The defendants in the mandamus action responded to the filing of the amended complaint by filing preliminary objections in the nature of a demurrer. After a hearing President Judge Crumlish denied the County's motion for a preliminary injunction on May 15, 1984;[3] the County appealed that determination to this Court. On September 6, 1984, the Commonwealth Court sustained the defendants' preliminary objections and dismissed the County's Complaint without leave to amend. 85 Pa.Commw. 73, 480 A.2d 1330 (1984). That order was also appealed to this Court.


*372 II.

A.
A demurrer can only be sustained where the complaint is clearly insufficient to establish the pleader's right to relief. Firing v. Kephart, 466 Pa. 560, 353 A.2d 833 (1976). For the purpose of testing the legal sufficiency of the challenged pleading a preliminary objection in the nature of a demurrer admits as true all well-pleaded, material, relevant facts, Savitz v. Weinstein, 395 Pa. 173, 149 A.2d 110 (1959); March v. Banus, 395 Pa. 629, 151 A.2d 612 (1959), and every inference fairly deducible from those facts, Hoffman v. Misericordia Hospital of Philadelphia, 439 Pa. 501, 267 A.2d 867 (1970); Troop v. Franklin Savings Trust, 291 Pa. 18, 139 A. 492 (1927). The pleader's conclusions or averments of law are not considered to be admitted as true by a demurrer. Savitz v. Weinstein, supra.
Since the sustaining of a demurrer results in a denial of the pleader's claim or a dismissal of his suit, a preliminary objection in the nature of a demurrer should be sustained only in cases that clearly and without a doubt fail to state a claim for which relief may be granted. Schott v. Westinghouse Electric Corp., 436 Pa. 279, 259 A.2d 443 (1969); Botwinick v. Credit Exchange, Inc., 419 Pa. 65, 213 A.2d 349 (1965); Savitz v. Weinstein, supra; London v. Kingsley, 368 Pa. 109, 81 A.2d 870 (1951); Waldman v. Shoemaker, 367 Pa. 587, 80 A.2d 776 (1951). If the facts as pleaded state a claim for which relief may be granted under any theory of law then there is sufficient doubt to require the preliminary objection in the nature of a demurrer to be rejected. Packler v. State Employment Retirement Board, 470 Pa. 368, 371, 368 A.2d 673, 675 (1977); see also Schott v. Westinghouse Electric Corp., supra, 436 Pa. at 291, 259 A.2d at 449.

B.
Mandamus is an extraordinary remedy designed to compel official performance of a ministerial act or mandatory *373 duty where there exists a clear legal right in the plaintiff, a corresponding duty in the defendant and want of any other adequate remedy at law. See Equitable Gas Co. v. City of Pittsburgh, 507 Pa. 53, 488 A.2d 270 (1985); Shaler Area School District v. Salakas, 494 Pa. 630, 432 A.2d 165 (1981); Canonsburg General Hospital v. Department of Health, 492 Pa. 68, 422 A.2d 141 (1980); Bronson v. Commonwealth, Board of Probation and Parole, 491 Pa. 549, 421 A.2d 1021 (1980), cert. denied, 450 U.S. 1050, 101 S.Ct. 1771, 68 L.Ed.2d 247 (1981); Philadelphia Newspapers, Inc. v. Jerome, 478 Pa. 484, 387 A.2d 425 (1978), appeal dismissed, 443 U.S. 913, 99 S.Ct. 3104, 61 L.Ed.2d 877 (1979); Princeton Sportswear Corp. v. Redevelopment Authority, 460 Pa. 274, 333 A.2d 473 (1975); Valley Forge Racing Association v. State Horse Racing Commission, 449 Pa. 292, 297 A.2d 823 (1972); Martin v. Garnet Valley School District, 441 Pa. 502, 272 A.2d 913 (1971); Garchinsky v. Borough of Clifton Heights, 437 Pa. 312, 263 A.2d 467 (1970). Where the action sought to be compelled is discretionary, mandamus will not lie to control that discretionary act, see Bronson v. Commonwealth Board of Probation and Parole, supra; Citizens Committee to Recall Rizzo v. Board of Elections, 470 Pa. 1, 367 A.2d 232 (1976); Kremer v. Shoyer, 453 Pa. 22, 311 A.2d 600 (1973); Porter v. Bloomsburg State College, 450 Pa. 375, 301 A.2d 621 (1973), cert. denied, 414 U.S. 844, 94 S.Ct. 105, 38 L.Ed.2d 82 (1973), but courts will review the exercise of the actor's discretion where it is arbitrary or fraudulently exercised or is based upon a mistaken view of the law. Coleman v. Board of Education of School District of Philadelphia; 477 Pa. 414, 383 A.2d 1275 (1978); Valley Forge Racing Ass'n., Inc. v. State Horse Racing Commission, supra; Young Men & Women's Hebrew Ass'n. v. Borough Council of Borough of Monroeville, 429 Pa. 283, 240 A.2d 469 (1968); Commercial Properties, Inc. v. Peternel, 418 Pa. 304, 211 A.2d 514 (1965); Commonwealth v. Caplan, 411 Pa. 563, 192 A.2d 894 (1963); Garratt v. Philadelphia, 387 Pa. 442, 127 A.2d 738 (1956); Maxwell v. Farrell School *374 District Board of Directors, 381 Pa. 561, 112 A.2d 192 (1955); Travis v. Teter, 370 Pa. 326, 87 A.2d 177 (1952).

III.

A.
The difficulty the County encountered in the Commonwealth Court is in large measure the result of its inartful pleading.[4] In the amended complaint the County alleges in paragraphs 19-21 the refusal of the Deputy Commissioner of the Bureau to authorize the transfer of inmates from the County's facilities pursuant to the Act of July 11, 1923, P.L. 1044, § 1, as amended 61 P.S. § 72.[5]
*375 Section 72 clearly vests discretion in the Deputy Commissioner to determine whether the requested transfers should be approved. The Commonwealth Court properly dismissed this contention noting that even after amendment it failed to allege that the Deputy Commissioner acted arbitrarily in refusing the request or that it was based on a mistaken view of the law. Garrett v. Philadelphia, supra.
The County also alleged in its amended complaint [see paragraphs 22-24, 28] that the Bureau although authorized by the provisions of the Act of October 16, 1972, P.L. 913, No. 218, § 4, 61 P.S. § 460.14, has failed or refused to transfer female inmates to state regional community treatment centers.[6] Here again discretion is vested in the Bureau *376 and the allegations failed to charge the type of abuse of that discretion which would warrant relief in an action in mandamus. Coleman v. Board of Education of School District of Philadelphia, supra; Valley Forge Racing Ass'n., Inc. v. State Horse Racing Commission, supra; Young Men & Women's Hebrew Ass'n. v. Borough Council of Borough of Monroeville, supra; Commercial Properties, Inc. v. Peternel, supra; Commonwealth v. Caplan, supra; Garratt v. Philadelphia, supra; Maxwell v. Farrell School District Board of Directors, supra; Travis v. Teter, supra.
However, in this context it must be remembered that it is the State's obligation to maintain order and to preserve the safety and welfare of all citizens. Commonwealth v. Mikulan, 504 Pa. 244, 470 A.2d 1339 (1983); Jackson v. Hendrick, 498 Pa. 270, 284, 446 A.2d 226, 232 (1982) (Nix, J., dissenting); Best v. Zoning Board of Adjustment, 393 Pa. 106, 141 A.2d 606 (1958); Commonwealth ex rel. Woodside v. Sun Ray Drug Co., 383 Pa. 1, 116 A.2d 833 (1955); Gambone v. Commonwealth, 375 Pa. 547, 101 A.2d 634 (1954); Commonwealth v. Stofchek, 322 Pa. 513, 185 A. 840 (1936); White's Appeal, 287 Pa. 259, 134 A. 409 (1926); Powell v. Commonwealth, 114 Pa. 265, 7 A. 913 (1887) aff'd. 127 U.S. 678, 8 S.Ct. 992, 32 L.Ed. 253 (1888). That responsibility requires the governmental unit to provide adequate and secure facilities for the housing of those individuals who have demonstrated by their conduct that they pose a danger to the other members of society. The sovereign governmental power is reposed in the state. United States v. Board of Finance and Review, 369 Pa. 386, 85 A.2d 156 (1951); Commonwealth v. First National Bank and Trust Co. of Easton, 303 Pa. 241, 154 A. 379 (1931). Although it is entirely proper and indeed customary for the state to delegate a portion of that obligation among its political subdivisions, Jackson v. Hendrick, supra, 498 *377 Pa. at 284-85, 446 A.2d at 233 (Nix J., dissenting); United Tavern Owners of Philadelphia v. School District of Philadelphia, 441 Pa. 274, 272 A.2d 868 (1971); School District of Philadelphia v. Zoning Board of Adjustment, 417 Pa. 277, 207 A.2d 864 (1965); Cleaver v. Board of Adjustment of Tredyffrin Township, 414 Pa. 367, 200 A.2d 408 (1964); Gagliardi v. Ambridge Borough, 401 Pa. 141, 163 A.2d 418 (1960); Genkinger v. City of New Castle, 368 Pa. 547, 84 A.2d 303 (1951); Lighton v. Township of Abington, 336 Pa. 345, 9 A.2d 609 (1939), such delegation of responsibility does not relieve the state of its primary duty to assure the satisfactory discharge of the obligation.
Proceeding from the premise that the State bears the primary responsibility and that the State must provide the political subdivision with the taxing power, see Mastrangelo v. Buckley, 433 Pa. 352, 250 A.2d 447 (1969); Fischer v. Pittsburgh, 383 Pa. 138, 118 A.2d 157 (1955); Evans v. West Norriton Township Municipal Authority, 370 Pa. 150, 87 A.2d 474 (1952); Garr v. Fuls, 286 Pa. 137, 133 A. 150 (1926), or the appropriations, see In re Schmidt, 494 Pa. 86, 429 A.2d 631 (1981); Shapp v. Sloan, 480 Pa. 449, 391 A.2d 595 (1978), appeal dismissed sub nom. Thornburgh v. Casey, 440 U.S. 942, 99 S.Ct. 1415, 59 L.Ed.2d 630 (1979), necessary to discharge its statutorily delegated duty to provide detention facilities, the exercise of the discretion of a state official in refusing a request to provide alternative custodial facilities must be measured against the adequacy of the resources made available to the political subdivision to meet this need. See, e.g., Commonwealth ex rel. Carroll v. Tate, 442 Pa. 45, 274 A.2d 193, cert. denied, 402 U.S. 974, 91 S.Ct. 1665, 29 L.Ed.2d 138 (1971). Moreover, it is not the burden of the political subdivision to establish that the state has available facilities for such a transfer. Rather, where the political subdivision can demonstrate that its resources for these purposes are clearly inadequate, it is the responsibility of the State to either provide additional facilities or to allocate to the political subdivision reasonable funds to discharge its delegated *378 responsibility. See In re Schmidt, supra; Commonwealth ex rel. Carroll v. Tate, supra. Such relief is properly accorded in an action sounding in mandamus, Coleman v. Board of Education of School District of Philadelphia, supra; Valley Forge Racing Ass'n., Inc. v. State Horse Racing Commission, supra; Young Men & Women's Hebrew Ass'n. v. Borough Council of Borough of Monroeville, supra; Commercial Properties, Inc. v. Peternel, supra; Commonwealth v. Caplan, supra; Garratt v. Philadelphia, supra; Maxwell v. Farrell School District Board of Directors, supra; Travis v. Teter, supra, and upon remand the County is to be afforded an opportunity to amend its pleadings, if it is able to establish that they have not been provided adequate resources to meet the current needs.

B.
Unlike the complaints discussed up to this point which depended upon the exercise of discretion of a state official, paragraph 25 of the amended complaint sets forth five (5) categories of inmates who the County alleges are properly within the custody of the Bureau or the Board and therefore contends that they should not be housed in their County facilities in view of the present difficulties in housing those prisoners for which it is responsible.
Those subdivisions are:
a) Inmates which have been sentenced to terms of incarceration in state correctional facilities who are housed in the County Jail awaiting various hearings and Court appearances, i.e. awaiting Post Conviction Hearing Act hearings, awaiting appearances before the Court of Common Pleas of Allegheny County as a witness in other proceedings or trial on other charges.
b) Inmates who have been paroled from a state correctional facility by the Board of Probation and Parole and have committed an act or acts in violation of the terms of their parole and are awaiting a hearing by that Board prior to recommitment to a state facility.

*379 c) Inmates who have been paroled from a state correctional facility by the Board of Probation and Parole and have been charged with new criminal acts and are awaiting trial on those charges.
d) Inmates who have been convicted of criminal offenses and placed on probation under the supervision of the Board of Probation and Parole and have committed an act or acts in violation of the terms of their probation and are awaiting a hearing by the Court of Common Pleas of Allegheny County.
e) Inmates who have been convicted of criminal offenses and placed on probation under the supervision of the Board of Probation and Parole and have been charged with new criminal offenses and are awaiting trial on the new charge.
The Bureau is the Commonwealth agency directly responsible for the state correctional system and its facilities. Act of July 27, 1953, P.L. 1428, § 1, as amended, 71 P.S. §§ 301, 302, 732-502. The Bureau must accept and confine all persons committed to its custody pursuant to 42 Pa.C.S. § 9762. That statute provides in pertinent part:
All persons sentenced to total or partial confinement for:
(1) maximum terms of five or more years shall be committed to the Bureau of Correction for confinement;
(2) maximum terms of two years or more but less than five years may be committed to the Bureau of Corrections for confinement or may be committed to a county prison within the jurisdiction of the court;
. . . .
Under subsection (1) of this section all males receiving a maximum sentence of five years or more are committed to the custody of the Bureau. In these cases there is no discretion to be exercised by the Bureau; rather the legislature has directed where custody is to be vested and the Bureau has no choice but to provide placement in one of its facilities for confinement. For prisoners who receive a maximum sentence of two years or more but less than five years the decision as to the responsibility for custody is *380 vested in the sentencing court and not the Bureau. 42 Pa.C.S. § 9762(2). Thus here again there is no discretion vested in the Bureau as to the assignment of custody for confinement but rather that decision is within the sound discretion of the trial judge.
Turning to subdivision (a) of the amended complaint, those inmates who were sentenced to terms of incarceration in state correctional facilities either pursuant to section 9762(1) or (2) were in neither case placed in state custody as a result of the Bureau's exercise of discretion. In the former instance the placement resulted from the length of the maximum sentence pursuant to statute and in the latter the custody decision rested with the judgment of the sentencing judge. In both instances the role of the Bureau in this connection was a ministerial one and therefore an appropriate subject for an action in mandamus if the Bureau refused upon direction to perform that function.[7]
While considerations of comity and convenience would normally encourage the housing of state prisoners temporarily in County facilities where the inmate is required for court appearances in the County, these considerations must give way during a period of crisis such as is presently occurring. Where the County facility is unable to meet constitutional standards because of overcrowding and where the security of the institution is threatened, the County cannot be expected to accord such a courtesy to the State and thereby further exacerbate their situation. The County, relying upon the Bureau's statutory responsibility to house inmates in this category, went to court to compel the Bureau to take custody of those prisoners in the County Jail already committed to the Bureau's sole legal custody. *381 In this instance the County clearly demonstrated the right to relief necessary to maintain an action in mandamus.
The inmates in category (b) are likewise clearly state prisoners. As described in the County's complaint, they are prisoners formerly committed to state correctional facilities paroled by the Board detained as parole violators pending Board revocation proceedings. As parolees these prisoners are within the exclusive custody of the Board. 37 Pa.Code §§ 63.2, 75.2. The Board, which has the exclusive authority to parole and to recommit, 61 P.S. § 331.7, is the sole cause of their incarceration in the County, having arrested these individuals and issued warrants for their detention. See 37 Pa.Code § 71.1. Thus these inmates, while physically in Allegheny County, are in state custody.
As to category (c) it is argued by the County that it has limited this class to those prisoners who would have been able to make bail but have failed to do so because of a detainer lodged against them by the Board. For the County's purposes, the release of these prisoners was appropriate. It is the State which insists upon confinement. If the County can establish that there are prisoners in this category who would not be in the Jail but for Board detainers, such inmates, like those in category (b), must be deemed state prisoners. Whether the County can prove the facts necessary to establish state custody is not an appropriate question at the demurrer stage.
The prisoners in category (d) are state prisoners for the same reasons as the inmates in category (b). They are in the exclusive custody of the Board and are incarcerated solely on Board detainers.
Finally, inmates in category (e) who would have been released on bail by the County but for Board detainers are state prisoners in the custody of the Board for the same reasons as the prisoners in category (c).[8]
*382 We conclude, therefore, that, accepting as true the averments in the County's amended complaint with respect to these five classes of inmates, that complaint pleads facts sufficient to establish both a clear legal right in the County and a corresponding duty on the part of the Bureau and the Board for purposes of a demurrer. Since the remaining element of a cause of action in mandamus, absence of any other adequate remedy at law, is properly pleaded, the complaint states a viable cause of action and must be reinstated to permit the County to establish that inmates who fall within the categories discussed above are in fact being housed in the County Jail.[9]

IV.
Since the complaint must be reinstated, we must address the question of whether the County's motion for a preliminary injunction was improperly denied. The standard of review to be employed in our determination is well settled.
[O]n an appeal from the grant or denial of a preliminary injunction, we do not inquire into the merits of the controversy, but only examine the record to determine if there were any apparently reasonable grounds for the action of the court below. Only if it is plain that no grounds exist to support the decree or that the rule of law relied upon was palpably erroneous or misapplied will we interfere with the decision of the Chancellor. Intraworld Industries, Inc. v. Girard Trust Bank, 461 Pa. 343, 336 A.2d 316 (1975); Credit Alliance Corp. v. Philadelphia Minit-Man Car Wash Corp., 450 Pa. 367, 301 A.2d 816 (1973); Zebra v. Pittsburgh School District, 449 *383 Pa. 432, 296 A.2d 748 (1972). "In order to sustain a preliminary injunction, the plaintiff's right to relief must be clear, the need for relief must be immediate, and the injury must be irreparable if the injunction is not granted." Zebra v. Pittsburgh School District, 449 Pa. at 437, 296 A.2d at 750.

Roberts v. School District of Scranton, 462 Pa. 464, 469, 341 A.2d 475, 478 (1975).
In addition, "a preliminary injunction containing mandatory provisions which will require a change in the position of the parties should be granted even more sparingly than one which is merely prohibitory." Township of Fayette v. Commonwealth, 477 Pa. 574, 580, 385 A.2d 344, 347 (1978), citing McMullan v. Wohlgemuth, 444 Pa. 563, 281 A.2d 836 (1971). Accord, Zebra v. Pittsburgh School District, 449 Pa. 432, 296 A.2d 748 (1972). The County sought to enjoin the Bureau and the Board from failing or refusing to authorize the transfer of inmates from the Jail to state correctional facilities. While stated in the negative, the requested relief clearly involves affirmative action by the defendants and a change in the status quo.
The Commonwealth Court readily conceded the County's need for immediate relief and the threat of irreparable harm to the County and to the public. See fn. 2, supra. The mandated release of prisoners awaiting trial is a matter of extreme public concern and must be avoided if at all possible. The transfer of state prisoners to state facilities pending the outcome of the County's mandamus action will greatly alleviate the County's immediate problems. In view of our conclusion that any male inmates currently housed in the County Jail who fall into one of the five categories described by the County are properly in the custody of the Bureau or the Board, the County's motion for a preliminary injunction to compel the transfer of such prisoners established the requisite showing of a clear legal right to relief.
We find that the County's request satisfied the stringent criteria for the grant of a mandatory preliminary injunction *384 and can discern no reasonable ground for the denial of interim relief. Thus the Commonwealth Court's denial of the County's motion must be reversed and a preliminary injunction issued.

V.
Accordingly, the Order of the Commonwealth Court sustaining preliminary objections in the nature of a demurrer is vacated, the County's amended complaint in mandamus is reinstated with leave to amend, and the cause is remanded for further proceedings consistent with this opinion. The Order of the Commonwealth Court denying the County's motion for a preliminary injunction is reversed and it is ordered that a preliminary injunction issue instructing the Bureau and the Board to take immediate physical custody of all male State prisoners in any of the five categories identified by the County who are currently housed in the County Jail.
NOTES
[1]  By the Act of December 30, 1984, P.L. ___ No. 245, the Bureau became the Department of Correction.
[2]  The appellees argue that the county improperly invoked the Commonwealth Court's original jurisdiction and the appeal should be quashed. We note from the record below that this jurisdictional question was not raised in the Commonwealth Court nor has a formal motion to quash been filed in this Court.

Although a question of jurisdiction may be raised sua sponte by the Court, Commonwealth v. Little, 455 Pa. 163, 314 A.2d 270 (1974); Daly v. School District of Darby Township, 434 Pa. 286, 252 A.2d 638 (1969); Harris-Walsh, Inc. v. Borough of Dickson City, 420 Pa. 259, 216 A.2d 329 (1966); Balazick v. Dunkard-Bobtown Municipal Authority, 414 Pa. 182, 199 A.2d 430 (1964), we decline to do so here where the issue to be addressed in this opinion was clearly a matter appropriate for the Commonwealth Court's original jurisdiction.
[3]  After acknowledging that Allegheny County had exercised its best efforts to comply with the quotas set by the United States District Court, President Judge Crumlish reluctantly concluded that the County's request for a preliminary injunction had to be denied. The court found that "the situation created by the federal court has indeed resulted in irreparable harm to Allegheny County." County of Allegheny v. Commonwealth, No. 3649 G.D.1983 (Pa.Commw. May 15, 1984) (Crumlish, P.J.) mem. op. at 3. The decision to refuse injunctive relief was apparently based upon the premise that the County had the burden of showing that the state had adequate facilities available. Such an analysis ignores the basic issue involved which was whether the county or the state had the primary responsibility.
[4]  We agree with the observation made by Judge Craig in his dissenting opinion:

Although the majority decision is understandable in view of the fact that the county has already once amended its complaint or petition, a matter of this grave public importance  affecting the safety of a metropolitan area from potential crime  should not go down to final decision on the basis of an inadequacy in pleading. County of Allegheny v. Commonwealth, 85 Pa.Commw. 73, 78, 480 A.2d 1330, 1333 (1984) (Craig, J., dissenting).
[5]  § 72. Transfer between Institutions; petition and order; consent of common pleas; retransfer

The Deputy Commissioner for Treatment of the Bureau of Correction in the Department of Justice is hereby authorized and empowered and, upon petition being presented to him by the board of inspectors, if there be such board, otherwise the superintendent or official in charge of any penitentiary, prison, workhouse, house of correction, or other institution for adult prisoners, located within any county, or by the county commissioners of the county in which the institution is located, setting forth that the said penitentiary, prison, workhouse, house of correction, or other institution for adult prisoners, cannot, by reason of overcrowded condition or other existing conditions, furnish proper and sufficient accommodations for the care, custody, control, and safety of the inmates thereof, and that it is requested that a certain number of inmates, set forth in such petition, should be transferred therefrom, may make an order authorizing and directing the said board of inspectors, if there be such board, otherwise the superintendent or official in charge, to transfer to another prison, penitentiary, workhouse, house of correction, or other institution for adult prisoners, such person or persons whom the board of inspectors, if there be such board, otherwise the superintendent or official in charge, shall specify and designate: Provided, however, That before any transfer is made as aforesaid the court of common pleas of the county wherein any such penitentiary, prison, workhouse, house of correction, or any other institution for adult prisoners is located, shall give its consent to such transfer. In the event of the overcrowded condition or other existing condition of such penitentiary, prison, workhouse, house of correction, or other institution for adult prisoners, be remedied, so that it shall again be able to furnish proper and sufficient accommodations for the care, custody, control, and safety of inmates thereof, the Deputy Commissioner is hereby authorized and empowered, upon petition being presented to him by the said board of inspectors, if there be such board, or by the superintendent or other official in charge, or by the county commissioners of the county in which the institution is located, to retransfer to said penitentiary, prison, workhouse, house of correction, or other institution for adult prisoners, any or all inmates heretofore transferred under the terms of this act.
61 P.S. § 72 (emphasis added).
[6]  § 460.14 Criteria for reception of female prisoners

The regional community treatment centers shall receive, subject to the affirmative authorization of the Bureau of Correction, the following:
(1) Females sixteen years or over received by commitment or sentence of the criminal courts;
(2) Women detained in default of bond after preliminary hearing unless the Bureau of Correction affirmatively authorized the use of a county jail in a specific county;
(3) Women detained in default of bond upon arrest if the Bureau of Correction so authorizes, and at the same time, prohibits use of a particular county jail for female commitments except on an emergency basis;
(4) Women sentenced by justices of the peace with authorization for temporary release by the Bureau of Correction and paroled by the court of common pleas without consent of justices of the peace;
(5) Females sentenced by the court of common pleas (i) who remain under county jurisdiction; (ii) who are under State jurisdiction;
(6) Females who are alleged or determined to be in violation of their parole (county or State, convicted or technical). 61 P.S. § 460.14.
[7]  Section 9762(3) in contrast to the earlier subsections does provide discretion to the Bureau in the placement decision. However, we do not interpret subdivision (a) of the amended complaint as referring to prisoners placed in State facilities under § 9762(3). Subdivision (a) refers to a direct sentence to a State correctional institution. Section 9762(3) refers to an initial commitment to a county prison although the prisoner may subsequently be transferred to a State facility.
[8]  In view of our conclusion that the County has a remedy in mandamus, we need not address the viability of the County's alternative count in equity.
[9]  It is argued by appellees that the County has raised additional theories on appeal which were not addressed to the Commonwealth Court and thus should not be considered by this Court. It is our view, however, that the County has merely identified additional legal authority in support of its claims; the County's basic theory is the same as that set forth in its amended complaint. While that complaint left something to be desired as regards citation to specific statutory provisions, this belated clarification of the County's claims should not inure to its prejudice. Thus a finding of waiver would be inappropriate.
