
607 N.W.2d 561 (2000)
2000 ND 39
STATE of North Dakota, Plaintiff and Appellee,
v.
Abbas Shariff ABDULLAHI, Defendant and Appellant.
No. 990243.
Supreme Court of North Dakota.
March 21, 2000.
*562 Adam W. Hamm, Assistant State's Attorney, Fargo, for plaintiff and appellee.
David J. Chapman, Gjesdahl & Deitz, PLLP, Fargo, for defendant and appellant.
KAPSNER, Justice.
[¶ 1] Abbas Shariff Abdullahi appealed from an order denying his motion to withdraw his guilty plea. We hold deportation and mandatory, indefinite detention under federal immigration laws are collateral consequences of a guilty plea to a state criminal charge, and a trial court need not advise a defendant about those consequences before accepting a guilty plea under N.D.R.Crim.P. 11. We affirm.

I
[¶ 2] In July 1998, Abdullahi, a Somalian native and citizen who had been admitted into the United States in 1996, was charged with gross sexual imposition under N.D.C.C. § 12.1-20-03(1)(d) for allegedly engaging in a sexual act with a victim less than fifteen years old. Abdullahi appeared with an interpreter at his initial appearance on July 14, 1998, and the court informed him:
Okay. First of all you all have the right to be present at all stages of the proceedings. You have the right to assistance of legal counsel at all stages of the proceedings. You have the right to remain silent except to enter a plea of guilty or not guilty. You have the right to a jury trial upon the entry of a not guilty plea. And you may, if the State's Attorney agrees and the Court agrees, waive your right to a jury trial and have your case tried before the Judge without a jury. If you are tried before a jury, a unanimous verdict of guilty is required before you can be convicted. If you waive your right to a jury trial, your case will be tried before the Judge without a jury.
You have the right to confront the witnesses the State will call against you to testify. And you have the right to the use of subpoena powers of the State of North Dakota to compel witnesses to testify in your own defense. You have a right to a reasonable delay with in which to prepare a defense. And you have the right to have a trial without ever taking the witness stand and no one is to comment upon that to the jury. That is, you do not have to testify at your own trial.
You are presumed innocent unless and until the State can prove you guilty beyond a reasonable doubt. You have the right to a speedy trial. And you have the right to a public trial. And you have the right to be admitted to reasonable bail. You have the right to a reasonable delay with in which time you can prepare your own defense, if I didn't tell you that.
If an attorney is appointed to represent you at public expense, you may have to pay attorney's fees at a later time in an amount to be determined by the Judge.
If you are not a citizen of the United States and you are convicted of a crime either by pleading guilty or by a trial, you may be deported to another country.

*563 If you are presently on probation in this jurisdiction or any other jurisdiction in the United States and you are convicted of a crime, your probation may be revoked and you may be re-sentenced to a term of imprisonment.
If you are convicted of a sex crime, you will have to register your whereabouts in the United States for a minimum of ten years. And depending on the nature of the sex crime, possibly for the rest of your life.
....
So what he's facing is if he's found guilty by pleading guilty or by a trial, he's facing up to twenty years in prison and possibly a fine of Twenty Thousand Dollars and registering his whereabouts wherever he lives in the United States for years to come. And possible deportation to another country. What they're alleging is that he engaged in a sexual act with a 13 year old girl and that's underage.
[¶ 3] On August 6, 1998, Abdullahi appeared with an interpreter and court-appointed counsel at a scheduled preliminary hearing. Abdullahi waived his right to the preliminary hearing and pled not guilty to the charge. After informing Abdullahi of the maximum penalties for conviction and the requirement for registration as a sex offender under North Dakota law, the court again informed him "if he's convicted, he may be deported to another country. I think I told him that last time. If he's not a United States citizen."
[¶ 4] On September 28, 1998, Abdullahi, with an interpreter and court-appointed counsel, attempted to plead guilty to the charge. The court refused to accept Abdullahi's guilty plea, however, because he claimed he did not have sexual intercourse with the victim.
[¶ 5] On November 9, 1998, Abdullahi appeared with an interpreter and court-appointed counsel and withdrew his not guilty plea. The following colloquy occurred:
THE COURT: Okay. Then I'm going to ask you some questions and have you answer your interpreter out loud. Do you understand, sir, you have the right to plead guilty or not guilty?
INTERPRETER: Yes, Your Honor.
THE COURT: Okay and that is to the charge of Gross Sexual Imposition? You understand that?
INTERPRETER: Yes, Your Honor.
THE COURT: Did you hear and understand the Constitutional Rights the Court gave you on an earlier date?
INTERPRETER: Yes, Your Honor.
THE COURT: Do you understand the nature of this charge, Count One, Gross Sexual Imposition?
INTERPRETER: Yes, sir.
THE COURT: And do you understand, sir, that if you plead guilty the maximum penalty you can face is twenty years in prison and/or a Twenty Thousand Dollar fine.
INTERPRETER: Yes, sir.
THE COURT: And do you understand that you will have to register as a sex offender?
INTERPRETER: Yes, sir.
THE COURT: Do you understand that if you plead guilty, you will be waiving your rights to any trial proceedings of any kind and your right to cross examine those witnesses who would have taken the stand and testified against you if you had gone to trial?
INTERPRETER: Yes.
THE COURT: Okay. Has anyone threatened you in any way in an attempt to get you to enter a guilty plea here today?
INTERPRETER: No.
THE COURT: Has anyone promised you anything in an attempt to get you to enter a guilty plea here today?
INTERPRETER: No.
THE COURT: Has anyone threatened to use force against you in an *564 attempt to get you to enter a guilty plea here today?
INTERPRETER: No.
THE COURT: Are you satisfied with your counsel's representation of you this far in the case?
INTERPRETER: Yes.
THE COURT: And are you under the influence of any drugs including alcohol at this time?
INTERPRETER: No.
The court accepted Abdullahi's guilty plea, and in January 1999, sentenced him to one year in custody with all but six months suspended for two years.
[¶ 6] Abdullahi's conviction for gross sexual imposition subjected him to adverse immigration consequences as an "aggravated felon," which according to him, included mandatory, indefinite detention and automatic deportation. In July 1999, Abdullahi moved to withdraw his guilty plea. After a hearing, the trial court found Abdullahi had not established manifest injustice necessary to allow him to withdraw his guilty plea under N.D.R.Crim.P. 32(d) and denied his motion. Abdullahi appealed.

II
[¶ 7] Under N.D.R.Crim.P. 32(d), a trial court shall allow a defendant to withdraw a guilty plea whenever the defendant, upon a timely motion, proves withdrawal is necessary to correct a manifest injustice. State v. Trieb, 516 N.W.2d 287, 290 (N.D.1994). A manifest injustice may result from procedural errors by the trial court. State v. Farrell, 2000 ND 26, ¶ 8, 606 N.W.2d 524. The decision whether a manifest injustice exists for withdrawal of a guilty plea lies within the trial court's discretion and will not be reversed on appeal except for an abuse of discretion. State v. Hendrick, 543 N.W.2d 217, 219 (N.D.1996). An abuse of discretion under N.D.R.Crim.P. 32(d) occurs when the court's legal discretion is not exercised in the interest of justice. State v. Dalman, 520 N.W.2d 860, 862 (N.D.1994).
[¶ 8] Motions to withdraw guilty pleas under N.D.R.Crim.P. 32(d) must be considered in conjunction with N.D.R.Crim.P. 11, which governs a trial court's advice to a defendant before accepting a guilty plea and provides, in part:

(b) Advice to Defendant. The court may not accept a plea of guilty without first, by addressing the defendant personally [except as provided in Rule 43(c) ] in open court, informing the defendant of and determining that the defendant understands the following:
(1) The nature of the charge to which the plea is offered;
(2) The mandatory minimum punishment, if any, and the maximum possible punishment provided by the statute defining the offense to which the plea is offered;
(3) That the defendant has the right to plead not guilty, or to persist in that plea if it has already been made, or to plead guilty;
(4) That if the defendant pleads guilty there will not be a further trial of any kind, so that by pleading guilty the defendant waives the right to a trial by jury or otherwise and the right to be confronted with adverse witnesses; and
(5) If the defendant is not represented by an attorney, that the defendant has the right to be represented by an attorney at every stage of the proceedings against the defendant and, if necessary, one will be appointed to represent the defendant, as provided in Rule 44, North Dakota Rules of Criminal Procedure.
[¶ 9] The advice required by N.D.R.Crim.P. 11 is mandatory. Farrell, 2000 ND 26, ¶ 9, 606 N.W.2d 524. Although N.D.R.Crim.P. 11 does not require a ritualistic, predetermined formality, a trial court must substantially comply with the procedural requirements of the rule to ensure a defendant's guilty plea is voluntary. Farrell at ¶ 9. Under N.D.R.Crim.P. 11, a trial court must inform a defendant of all *565 "direct consequences" of a plea, but need not advise the defendant of "collateral consequences." Dalman, 520 N.W.2d at 863; Houle v. State, 482 N.W.2d 24, 30 (N.D.1992); see also Brady v. United States, 397 U.S. 742, 755, 90 S.Ct. 1463, 25 L.Ed.2d 747 (1970) (explaining guilty plea is voluntary if made by defendant fully aware of direct consequences).

A
[¶ 10] Abdullahi argues the trial court abused its discretion in refusing to allow him to withdraw his guilty plea, because he was not informed of the direct consequences of his plea. He argues deportation and mandatory, indefinite detention are direct consequences of his guilty plea, because they flow definitely, immediately, and automatically from his gross sexual imposition conviction.
[¶ 11] In Dalman, 520 N.W.2d at 863 n. 3, we considered a similar issue, and we assumed the defendant was involved in deportation proceedings. We said deportation was a collateral consequence of a guilty plea and "join[ed] the prevailing trend of states that have held sentencing courts need not inform defendants of the collateral consequence of deportation in order for pleas to be voluntary." Dalman at 863 citing Tafoya v. State, 500 P.2d 247 (Alaska 1972); Alpizar v. United States, 595 A.2d 991 (D.C.1991); State v. Hasnan, 806 S.W.2d 54 (Mo.Ct.App.1991); State v. Chung, 210 N.J.Super. 427, 510 A.2d 72 (1986); People v. Williams, 189 A.D.2d 910, 592 N.Y.S.2d 471 (N.Y.App.Div.1993); State v. Malik, 37 Wash.App. 414, 680 P.2d 770 (1984); State v. Baeza, 174 Wis.2d 118, 496 N.W.2d 233 (Wis.Ct.App.1993); Carson v. State, 755 P.2d 242 (Wyo.1988).
[¶ 12] Abdullahi argues 1996 amendments to federal immigration law after Dalman was decided have expanded the definition of aggravated felony to include gross sexual imposition. Relying on the test for "direct" consequences stated in Alanis v. State, 583 N.W.2d 573 (Minn.1998), he argues deportation and mandatory, indefinite detention are now definite, immediate, and automatic consequences of crimes that are classified as aggravated felonies under federal immigration law.
[¶ 13] In Alanis, 583 N.W.2d at 578, the State argued "direct consequences are those which flow definitely, immediately, and automatically from the guilty plea, namely, the maximum sentence to be imposed and the amount of any fine [;] ... any consequence that results from actions taken by other government agencies such as the INS are collateral[; and] deportation is a collateral consequence" of a guilty plea. The Minnesota Supreme Court found the State's argument persuasive, ruling:
It makes sense that direct consequences are those which flow definitely, immediately, and automatically from the guilty pleathe maximum sentence and any fine to be imposed. Further, it makes sense that deportation is not a direct consequence of the guilty plea because deportation is neither definite, immediate, nor automatic. Before a resident alien such as Alanis can be deported, the INS must exercise its discretion to commence deportation proceedings and, prior to deportation, there are various administrative procedures which must be followed.
We are satisfied from the record that Alanis, before pleading guilty, knew and understood the charges against him and his rights under the law as well as the direct consequences of making the plea, that being the maximum sentence and the amount of any fine to be imposed. Thus, we conclude that the postconviction court's decision that withdrawal of Alanis's guilty plea was not necessary to correct a manifest injustice was not error.
Alanis, 583 N.W.2d at 578-79 (footnote omitted).
[¶ 14] Abdullahi argues the test for "direct" consequences in Alanis is correct, but claims the result in that case is wrong because deportation and mandatory detention *566 are not discretionary. We need not define the federal immigration consequences of Abdullahi's guilty plea to the charge of gross sexual imposition under state law, and we assume federal law subjects him to deportation and mandatory, indefinite detention because of the conviction resulting from his guilty plea. See Dalman, 520 N.W.2d at 863 n. 3 (assuming defendant involved in deportation proceedings). We nevertheless decline to retreat from our decision in Dalman, and we hold a trial court is not required to advise a defendant about deportation and mandatory, indefinite detention before accepting a guilty plea to a state criminal charge.
[¶ 15] Other courts have uniformly held that deportation is a collateral consequence of a guilty plea, and under procedures similar to N.D.R.Crim.P. 11, a trial court is not required to inform a defendant about deportation before accepting a guilty plea. See United States v. Gonzalez, 202 F.3d 20, 2000 WL 39120 (1st Cir.2000); United States v. Osiemi, 980 F.2d 344, 349 (5th Cir.1993); United States v. Montoya, 891 F.2d 1273, 1292-93 (7th Cir.1989); United States v. Romero-Vilca, 850 F.2d 177, 179 (3d Cir.1988); Downs-Morgan v. United States, 765 F.2d 1534, 1538 (11th Cir.1985); Fruchtman v. Kenton, 531 F.2d 946, 949 (9th Cir.1976); Tafoya, 500 P.2d at 251; State v. Vera, 159 Ariz. 237, 766 P.2d 110, 112 (Ariz.Ct.App.1988); People v. Pozo, 746 P.2d 523, 526 (Colo.1987); State v. Nguyen, 81 Hawai'i 279, 916 P.2d 689, 697 (Haw.1996); Barajas v. Nevada, 991 P.2d 474, 476 (1999); People v. Ford, 86 N.Y.2d 397, 633 N.Y.S.2d 270, 657 N.E.2d 265, 267-68 (1995); State v. Figueroa, 639 A.2d 495, 499 (R.I.1994); Carson, 755 P.2d at 244. See generally 5 LaFave, Israel, and King, Criminal Procedure § 21.4(d) at p. 172 (2nd ed.1999); 1A Wright, Federal Practice and Procedure: Criminal 3d § 173, at p. 192 (1999).
[¶ 16] In Gonzalez, 202 F.3d at p. 26, in the context of an ineffective assistance of counsel claim, the defendant argued prior cases involving immigration consequences and guilty pleas had not "`aged well,'" because, under the 1996 amendments to federal immigration law, his "deportationor indefinite administrative detentionis `to be expected virtually by operation of law.'" The First Circuit Court of Appeals rejected that argument, explaining the "collateral nature of deportation is not affected by [the 1996] expansion of the `aggravated felon' category, because the immigration consequences of a plea are collateral irrespective of the reason for which an alien is deemed deportable." Id. at p. 26 The court said:
[F]ederal courtsincluding this onehave previously found various "automatic" consequences of conviction to be merely "collateral." See, e.g., Nunez Cordero v. United States, 533 F.2d 723, 726 (1st Cir.1976) ("We can readily imagine that a court might be willing to grant leave to withdraw" when defendant learned, post-plea, of "mandatory deportation" resulting from conviction, "[b]ut we cannot say that a court must grant leave."); United States v. Crowley, 529 F.2d 1066, 1072 (3d Cir.1976) (concluding that the automatic loss of a municipal job upon felony conviction was a collateral consequence of a plea); Meaton v. United States, 328 F.2d 379, 381 (5th Cir.1964) (automatic loss of rights to vote and to travel abroad upon felony conviction were collateral consequences of a plea). What renders the plea's immigration effects "collateral" is not that they arise "virtually by operation of law," but the fact that deportation is "not the sentence of the court which accept[s] the plea but of another agency over which the trial judge has no control and for which he has no responsibility." Fruchtman v. Kenton, 531 F.2d 946, 949 (9th Cir.1976) (quoting Michel v. United States, 507 F.2d 461, 465 (2d Cir.1974)); see also George, 869 F.2d at 337 (emphasizing that deportation "may result from a criminal prosecution, but is not a part of or enmeshed in the criminal proceeding"); Sanchez, 572 F.2d at 211 (noting that the key inquiry is whether a consequence "is controlled by an agency which operates beyond the direct authority of the trial judge"). However *567 "automatically" Gonzalez's deportationor administrative detentionmight follow from his conviction, it remains beyond the control and responsibility of the district court in which that conviction was entered and it thus remains a collateral consequence thereof.
Gonzalez, 202 F.3d at p. 27.
[¶ 17] The First Circuit Court of Appeals applied that rationale to reject the defendant's argument the trial court's failure to advise him of the immigration consequences of a guilty plea rendered the plea involuntary. Gonzalez, 202 F.3d at p. 27. The court held deportation is a collateral consequence of a guilty plea, and trial courts are not obligated to advise defendants of immigration consequences of a guilty plea before accepting the plea. Id.
[¶ 18] We agree with the rationale that "[w]hat renders the plea's immigration effects `collateral' is not that they arise `virtually by operation of law,' but the fact that deportation is `not the sentence of the court which accept[s] the plea of another agency over which the trial judge has no control and for which he has no responsibility.'" Gonzalez, 202 F.3d at p. 26, citing Fruchtman, 531 F.2d at 949, and Michel, 507 F.2d at 465. That rationale, coupled with the advice requirements in N.D.R.Crim.P. 11, provide the framework for assessing the direct or collateral consequences of a guilty plea, and we decline to extend a court's obligation to inform a defendant about the immigration consequences of a guilty plea beyond those direct consequences identified in N.D.R.Crim.P. 11.
[¶ 19] We conclude that, before accepting Abdullahi's guilty plea, the trial court was not required to advise him that his plea would subject him to deportation and mandatory, indefinite detention. Although not required, the trial court advised Abdullahi that he "may be deported to another country" if convicted of the crime, either by pleading guilty or by trial. We recognize deportation may be harsher than the criminal penalty imposed on Abdullahi. Under these circumstances, however, Abdullahi's argument that withdrawal of the guilty plea is necessary to correct a manifest injustice is not persuasive. We conclude the trial court did not abuse its discretion under N.D.R.Crim.P. 32(d) in refusing to allow Abdullahi to withdraw his guilty plea because deportation and mandatory, indefinite detention are collateral consequences of his plea.

B
[¶ 20] Abdullahi argues the trial court's admonition that, if convicted, he could spend 20 years in jail failed to inform him of the maximum possible penalty for the charge, because he was subject to mandatory, indefinite detention under federal immigration law.
[¶ 21] Rule 11(b)(2), N.D.R.Crim.P., precludes a trial court from accepting a guilty plea unless the court informs the defendant of the "mandatory minimum punishment, if any, and the maximum possible punishment provided by the statute defining the offense to which the plea is offered." Before accepting Abdullahi's guilty plea, the trial court informed him of the maximum possible penalty for a conviction for gross sexual imposition. We reject Abdullahi's argument he was not informed of the maximum penalty in this case, because mandatory, indefinite detention under federal immigration law is a collateral consequence of his state court conviction for gross sexual imposition. The trial court complied with N.D.R.Crim.P. 11(b)(2) in accepting Abdullahi's guilty plea, and we conclude the court did not abuse its discretion under N.D.R.Crim.P. 32(d) in denying his motion to withdraw his guilty plea on this basis.

III
[¶ 22] Abdullahi argues the trial court erred in denying his motion to withdraw his guilty plea because his conviction results in mandatory, indefinite detention under federal immigration law, which he claims is cruel and unusual punishment.
[¶ 23] Abdullahi was charged with gross sexual imposition under *568 N.D.C.C. § 12.1-20-03(1)(d), a class A felony which carries a maximum penalty of 20 years imprisonment, a fine of $10,000, or both. See N.D.C.C. § 12.1-32-01(2). The trial court sentenced Abdullahi to one year in custody with all but six months suspended for two years. We have said sentences within the minimum and maximum statutory limits are within the discretion of the trial court. State v. Garcia, 1997 ND 60, ¶ 53, 561 N.W.2d 599. The trial court's sentence was within the statutory limits imposed by state law for gross sexual imposition, and we reject Abdullahi's argument collateral immigration proceedings by federal authorities subjected him to cruel and unusual punishment in this state criminal proceeding. His remedy, if any, for alleged improper detention by the federal authorities is in federal court.[1] We conclude the trial court did not abuse its discretion under N.D.R.Crim.P. 32(d) in denying Abdullahi's motion to withdraw his guilty plea on this basis.

IV
[¶ 24] We affirm the district court order denying Abdullahi's motion to withdraw his guilty plea.[2]
[¶ 25] GERALD W. VANDE WALLE, C.J., and DALE V. SANDSTROM, WILLIAM A. NEUMANN, and MARY MUEHLEN MARING, JJ., concur.
NOTES
[1]  We note federal courts have recognized the availability of habeas corpus to review challenges to mandatory detention by federal authorities under federal immigration law. See Parra v. Perryman, 172 F.3d 954, 957 (7th Cir.1999); Alikhani v. Fasano, 70 F.Supp.2d 1124, 1128-29 (S.D.Cal.1999); Grant v. Zemski, 54 F.Supp.2d 437, 440 (E.D.Pa.1999); Aguilar v. Lewis, 50 F.Supp.2d 539, 543 (E.D.Va.1999); Velasquez v. Reno, 37 F.Supp.2d 663, 668 (D.N.J.1999).
[2]  On the same day Abdullahi appealed from the denial of his motion to withdraw his guilty plea, he also moved for correction of an illegal sentence under N.D.R.Crim.P. 35. The court denied Abdullahi's motion. In his principal brief to this Court, Abdullahi argued he was being indefinitely detained as part of immigration procedures, and that detention constituted an illegal sentence which must be corrected under N.D.R.Crim.P. 35. Abdullahi's notice of appeal does not state he appealed from the order denying his motion to correct his sentence. In his reply brief to this Court, Abdullahi conceded his argument about an illegal sentence is not properly before this Court.
