
574 N.W.2d 831 (1998)
1998 ND 33
STATE of North Dakota, Plaintiff and Appellant,
v.
Daniel Ray WIKA, Defendant and Appellee.
Criminal No. 970267.
Supreme Court of North Dakota.
February 12, 1998.
*832 Allen K. Albright, Assistant State's Attorney, Fargo, for plaintiff and appellant.
James F. Lester, Fargo, for defendant and appellee.
NEUMANN, Justice.
[¶ 1] The State appeals from the trial court's denial of its Rule 35(a), N.D.R.Crim. P., motion to correct an illegal sentence. We reverse the order denying the motion, vacate the illegal sentence, and remand for correction.
[¶ 2] Defendant Daniel Ray Wika was charged and pled guilty to terrorizing and aggravated assault, both class C felonies. Wika admitted to slashing a woman with a butcher knife, creating a four-inch slash, plus a quarter-inch puncture wound. Before Wika pled guilty, the State filed an amended information, giving the trial court and Wika notice of a two-year mandatory minimum sentence required by statute.
[¶ 3] On March 13, 1997, before Wika entered his plea, the trial court specifically asked Wika if he committed the crime and whether he was aware of the statutory penalties, including a mandatory minimum sentence of two years in jail. Wika pled guilty. The trial court ordered a presentence investigation. At the sentencing hearing, Wika was sentenced to one year at the Cass County jail. The State's Attorney attempted to make the trial court aware of the mandatory minimum sentence, but was not recognized.
[¶ 4] The State moved for correction of sentence under Rule 35(a) N.D.R.Crim.P. The trial court denied the State's motion on the premise Rule 35 was not intended to benefit the prosecution.
[¶ 5] The State appeals.

I.
[¶ 6] We must first decide whether this case is appealable. The right to appeal is statutory in nature. State v. Owens, 1997 ND 212, ¶ 6, 570 N.W.2d 217. The State may only appeal from orders designated under N.D.C.C. § 29-28-07. Section 29-28-07(4), N.D.C.C., allows the State to appeal from "[a]n order made after judgment affecting any substantial right of the state." We have already decided the State may appeal when the trial court grants a criminal defendant's motion to correct an illegal sentence, as affecting a substantial right of the state. State v. Vavrosky, 442 N.W.2d 433, 434-35 (N.D.1989); State v. Rueb, 249 N.W.2d 506, 508-09 (N.D.1976). Likewise, the trial court's order denying the State's motion to correct an illegal sentence also affects a substantial right of the State, and is appealable.

II.
[¶ 7] The State argues the trial court erred in concluding Rule 35(a), N.D.R.Crim. P., does not allow prosecutors the benefit of correcting an illegal sentence.
[¶ 8] Rule 35(a), N.D.R.Crim.P., provides: "The sentencing court may correct an illegal sentence at any time and may correct a sentence imposed in an illegal manner within the time provided herein for the reduction of sentence." Generally, a criminal defendant brings a Rule 35(a) motion to seek correction of an alleged illegal sentence. See, e.g. State v. Nace, 371 N.W.2d 129, 130 (N.D.1985) (allowing criminal defendant to appeal following motion for correction or reduction of sentence under Rule 35(a)).[1]
[¶ 9] In its order denying the State's motion for correction of an illegal sentence, the trial court stated: "this Court finds that the *833 State is not permitted to bring this motion pursuant to Rule 35(a)."
[¶ 10] We have not yet directly addressed whether prosecutors may use Rule 35(a) to correct an illegal sentence. However, prosecutor's have succeeded in using the rule. See State v. Meier, 447 N.W.2d 506, 507 (N.D. 1989) (affirming trial court's granting of State's motion to correct an illegal sentence when original sentence was not in compliance with mandatory minimum under N.D.C.C. § 12.1-32-02.1).
[¶ 11] On its face, the rule does not prohibit the State from bringing a motion for correction of an illegal sentence. Rule 35, N.D.R.Crim.P. North Dakota's Rule 35 is based on the Federal Rule 35.[2]See Rule 35, N.D.R.Crim.P., Explanatory Note. In construing our version of Rule 35, we have previously sought guidance from federal courts in interpreting the federal rule. State v. Trieb, 533 N.W.2d 678, 680-81 (N.D.1995). In United States v. Henry, the Fifth Circuit stated:
"Rule 35 on its face would appear to be enacted for the benefit of the defendants the correction or reduction of sentences. However, the correction of an illegal sentence does not necessarily mean that the correction will always result in a reduction of a sentence for a defendant. Where the court has imposed a sentence less than the statutory minimum, Rule 35 allows the court to bring the defendant back into court and increase the sentence.... It is clear then that Rule 35 does not exist solely for the benefit of the defendant. Instead, it balances the scales of justice."
United States v. Henry, 680 F.2d 403, 408 (5th Cir.1982) (relying in part on Bozza v. United States, 330 U.S. 160, 67 S.Ct. 645, 91 L.Ed. 818 (1947) (allowing for correction of illegal sentence, even when it increased the sentence)).
[¶ 12] This court has recognized, under Rule 35(a), an illegal sentence may be corrected at any time, even if the correction results in a harsher sentence for the defendant. Trieb, 533 N.W.2d at 680. While it is a rare occurrence for the State or the government to bring a motion for correction, it is clear that it is allowed. See 26 Moore's Federal Practice § 635App.102(3)(a) (3rd ed.1997); United States v. Corbitt, 13 F.3d 207, 210 (7th Cir.1993) (allowing government to bring a motion to correct an illegal sentence under Rule 35(a), F.R.Crim.P.).
[¶ 13] The trial court erred, as a matter of law, in ruling the State cannot bring a Rule 35(a) motion to correct an illegal sentence.

III.
[¶ 14] The State argues the trial court erred in denying its motion to correct an illegal sentence. The State asserts the sentence was illegal as it did not conform with the mandatory minimum sentence require by law. We agree.
[¶ 15] Generally, trial courts have significant discretion in criminal sentencing. State v. McClung, 529 N.W.2d 852, 852 (N.D. 1995). However, the trial court must act within statutory limits. A sentence in excess of a statutory provision or contrary to a statutory provision is an illegal sentence. State v. Ertelt, 1997 ND 15, ¶ 5, 558 N.W.2d 860 (quoting State v. Trieb, 516 N.W.2d 287, 292 (N.D.1994)). A sentence that does not conform with the letter of the authorizing criminal statute is erroneous. Bozza, 330 U.S. at 166, 67 S.Ct. 649. If the trial court has erred by imposing a sentence less than the statutory minimum, it is not only lawful to revoke an initial sentence and substitute a greater sentence that should have been imposed, it is the court's obligation to do so. United States v. Bishop, 487 F.2d 631, 633 (1st Cir.1973).
[¶ 16] The legislature validly exercises its police powers when defining what acts constitute criminal offenses, and establishing the minimum and maximum sentences for offenses. State v. Clinkscales, 536 N.W.2d 661, 666 (N.D.1995). "By enacting NDCC § 12.1-32-02.1, the legislature has removed all discretionary power from the trial court as to the minimum sentence to be imposed upon an individual whose crime falls *834 within the purview of the statute." Id. (citation omitted).
[¶ 17] In this case, Wika used a dangerous weapon and committed two class C felonies. Section 12.1-32-02.1(2), N.D.C.C., clearly requires a minimum of two years' imprisonment for those crimes committed. The trial court sentenced Wika to one year of imprisonment. Because the trial court erred in denying the State's motion and in refusing to correct the illegal sentence, we reverse the order denying the State's motion, vacate the illegal sentence, and remand for sentencing consistent with the law.
[¶ 18] VANDE WALLE, C.J., and MARING, MESCHKE and SANDSTROM, JJ., concur.
NOTES
[1]  The holding in Nace has been superceded in part by legislation, see N.D.C.C. 12.1-32-06.1, but its holding permitting a challenge to an illegal sentence is still sound. DeCoteau v. State, 504 N.W.2d 552, 556 (N.D.1993); State v. Johnson, 1997 ND 235, ¶ 10, 571 N.W.2d 372, 375.
[2]  The Federal Rule 35 has been modified to incorporate changes pertaining to federal sentencing guidelines. Rule 35, F.R.Crim.P. North Dakota's Rule 35 follows the federal rule prior to November 1987. See 26 Moore's Federal Practice § 635App.102(3)(a) (3rd ed.1997).
