This Court issued an opinion letter on March 5, 1990, dismissing a show cause order against the defendant because one of the three predicate convictions required for adjudication as an habitual offender was based on an invalid county ordinance, Fairfax County Code § 88-4-17. In her order subsequently presented to the Court for entry, defense counsel sought over the Commonwealth’s objection to have the Court vacate and dismiss as void the defendant’s conviction based on the invalid ordinance. For the reasons stated below, the defendant’s conviction is vacated and dismissed as void.
It is clear in Virginia that where a court lacks jurisdiction of the subject matter, its judgment is void. Thacker v. Hubard, 122 Va. 379 (1918); Commonwealth v. Lorrilard Co., 129 Va. 74 (1921). It is also clear that if the court’s judgment is void for lack of subject matter jurisdiction, the judgment may be collaterally attacked at any time and in any proceedings. See, e.g., Slaughter v. Commonwealth, 222 Va. 787, 793 (1981); Va. Supreme Court Rule 3A:9(c) (1990). Thus, the basic issue is whether *224a court has subject matter jurisdiction to convict a defendant for violating an invalid county ordinance.
The Court may only acquire subject matter jurisdiction by virtue of the constitution or a valid statute. See Thacker v. Hubard, 122 Va. 379 (1918); Shelton v. Sydnor, 126 Va. 625 (1920). See also Chicago & Northwestern Railway Co. v. Fachman, 125 N.W.2d 210, 213 (Iowa 1963) ("It is hornbook law" that "jurisdiction of the subject matter must be derived from a valid statute”). It follows, then, that a conviction based on an invalid statute may not be sustained because the court did not have subject matter jurisdiction to convict the defendant. Further, pursuant to the Supreme Court’s decision in Slaughter, the defendant may raise the issue in collateral proceedings.
The Virginia Supreme Court stated this principle expressly in its decision in Ex parte Rollins, 80 Va. 314, 317 (1885). In Rollins, the Court noted that if the defendant’s conviction was based on an invalid criminal statute, "the circuit court acquired no jurisdiction of the case" and therefore the defendant was allowed to raise the issue on collateral attack in habeas corpus proceedings. Ex parte Rollins, 80 Va. 314, 317 (1885). In Rollins, the Court relied on a number of United States Supreme Court decisions holding that it is proper to consider a collateral attack on the constitutionality of the underlying criminal statute in habeas corpus proceedings because the issue is one of subject matter jurisdiction and may be raised at any time. See, e.g.. Ex parte Siebold, 100 U.S. 371 (1879), Ex parte Royall, 117 U.S. 241 (1885).
Although it appears that neither the Virginia Supreme Court nor the Court of Appeals has expressly addressed the propriety of a collateral attack on a conviction based on the invalidity of the underlying criminal statute since 1885, several modern Virginia Supreme Court decisions addressing the issue in the context of a direct appeal indicate that the principle stated in Rollins is still valid. In Burnette v. Commonwealth, for example, the Virginia Supreme Court stated that the constitutionality of the underlying criminal statute may be challenged "in any place, in any way," because if a statute creating a crime and fixing the punishment is unconstitutional, there is "no crime at all and no penalty to inflict." 194 Va. 785, 786 (1953). Similarly, in Pine v. Commonwealth, *225the Virginia Supreme Court noted that where a criminal law is unconstitutional, the indictment for violating it is void because there is no crime. 121 Va. 812, 821 (1917). o See also Mitchell v. County of Hanover, 1 Va. App. 486, 489-490 (1986) (warrant for driving under the influence in violation of an invalid county ordinance failed to state "an offense and was, therefore, insufficient to form the basis of a conviction").
In addition, a majority of courts in other jurisdictions hold that a defendant may collaterally attack his conviction by claiming that it is based on an invalid statute. See 21 Am. Jur. 2d Criminal Law i 535; 22 C.J.S. Criminal Law § 157. See also State ex rel. Skinkis v. Treffert, 280 N.W.2d 316 (Wis. Ct. App. 1979); Alexander v. State, 480 S.2d 1212 (Fla. Dist. Ct. App. 1984); Kelley v. Meyers, 263 P. 903 (Or. 1928); People v. Katrinak, 185 Cal. Rptr. 869 (Cal. Ct. App. 1982).
The cases cited by the Commonwealth in support of its position that the defendant may not collaterally attack his conviction are distinguishable because they are based on errors made by the trial court which are nonjurisdictional and therefore subject only to direct challenge on appeal. In Morse v. Commonwealth, 6 Va. App. 466 (1988), the Court of Appeals held that the sufficiency of the evidence to convict the defendant does not implicate the lower court’s jurisdiction and therefore the issue may only be raised on direct appeal. The Virginia Supreme Court’s decision in Eagle, Star and British Dominion Ins. Co. v. Heller, 149 Va. 82 (1927), likewise stands for the proposition that the sufficiency of the evidence to convict may not be challenged in a collateral civil proceeding because it is not a claim that the court lacked jurisdiction to convict. In Whorley v. Commonwealth, 215 Va. 740 (1975), the Supreme Court held that a defendant may not collaterally attack an uncounselled misdemeanor conviction where only civil disabilities are threatened and that an underlying uncounselled misdemeanor conviction is valid in all respects, save the term of imprisonment imposed.
The Commonwealth also cites Walters v. Commonwealth, 8 Va. App. 262 (1989), to support its position that the defendant may not collaterally attack the validity of his underlying conviction in the present proceedings. In Walters, however, the defendant failed to prove that *226the underlying ordinance was invalid in the trial court. The Court of Appeals simply addressed the effects of this failure of proof in Walters and not the effect of an invalid statute on any resulting conviction.
Finally, the Commonwealth notes that the Virginia Supreme Court rejected a collateral attack on an injunction order, issued pursuant to an unconstitutional statute in Local 333B, United Marine Division v. Commonwealth, 193 Va. 773 (1952). However, the case stands simply for the proposition that an order of a court, even if erroneously granted, must be obeyed until it is corrected by reversal on appeal. Id. at 783. Significantly, the Court further notes that where a judgment is void and not merely erroneous, a collateral attack on a judgment is proper. Id. at 783 citing Deeds v. Gilmer, 162 Va. 157 (1934); Buchanan v. Buchanan, 170 Va. 458 (1938).
I conclude, therefore, that it is proper to vacate the defendant’s conviction for violating Fairfax County Code § 88-4-17 in the present case. The court did not have subject matter jurisdiction to convict the defendant of violating the ordinance because no crime existed over which the court could exercise its criminal jurisdiction. A collateral attack is thus proper.