Except as provided in subdivision 2, an alleged misdemeanor violation must be treated as a petty misdemeanor if the prosecuting attorney believes that it is in the interest of justice that the defendant not be imprisoned if convicted and certifies that belief to the court at or before the time of arraignment or pretrial hearing, and the court approves of the certification motion. Prior to the appointment of a public defender to represent a defendant charged with a misdemeanor, the court shall inquire of the prosecutor whether the prosecutor intends to certify the case as a petty misdemeanor. The defendant's consent to the certification is not required. When an offense is certified as a petty misdemeanor under this section, the defendant is not eligible for the appointment of a public defender.
Subdivision 1 does not apply to a misdemeanor violation of section 169A.20; 171.09, subdivision 1, paragraph (g); 171.306, subdivision 6; 609.224; 609.2242; 609.226; 609.324, subdivision 3; 609.52; or 617.23, or an ordinance that conforms in substantial part to any of those sections. A violation described in this subdivision must be treated as a misdemeanor unless the defendant consents to the certification of the violation as a petty misdemeanor.
Notwithstanding any other law, a conviction for a violation that was originally charged as a misdemeanor and was treated as a petty misdemeanor under subdivision 1 or the Rules of Criminal Procedure may not be used as the basis for charging a subsequent violation as a gross misdemeanor rather than a misdemeanor.