
20 So.3d 971 (2009)
John William LEHMKUHLE, Jr., Appellant,
v.
STATE of Florida, Appellee.
No. 2D08-4554.
District Court of Appeal of Florida, Second District.
October 16, 2009.
*972 James Marion Moorman, Public Defender, and Brad Permar, Assistant Public Defender, Bartow, for Appellant.
Bill McCollum, Attorney General, Tallahassee, and Tonja Rene Vickers, Assistant Attorney General, Tampa, for Appellee.
KELLY, Judge.
John Lehmkuhle appeals his judgment and sentence for grand theft. He argues that the trial court erred in denying his motion to withdraw his guilty plea without giving him an opportunity to be heard on the motion. We agree and reverse.
Lehmkuhle entered a guilty plea to grand theft. He had traded a generator stored on his property for a forklift. The party who obtained the generator did not realize Lehmkuhle did not own it, and he sold it. When the owners of the generator realized it was gone and could not be recovered, they reported the theft to the police. Lehmkuhle was arrested and charged with grand theft. According to the victim, the generator was going to be shipped to Haiti where it was urgently needed to supply power for medical equipment.
Lehmkuhle decided to enter a guilty plea. At the plea hearing, defense counsel advised the court that his client scored out to around fifteen months, but that he would be asking for a downward departure. The prosecutor attempted to find out the basis on which the departure was sought, but the court interrupted before defense counsel could answer and proceeded to take Lehmkuhle's plea. The plea colloquy was abbreviated, and no further mention was made regarding sentencing other than the court advising Lehmkuhle that grand theft was punishable by up to five years in prison.
At sentencing, defense counsel began by telling the court that he intended to argue that the need for restitution was greater than the need for imprisonment, that his client admitted he owed restitution for the generator, but he intended to dispute the value the victim had placed on the generator, and that he was "hoping he can pay the restitution on probation. And I believe [the prosecutor] will elaborate further on his position." In response, the prosecutor indicated that defense counsel
has simplified this quite a bit to the fact that if he believes restitution is the issue, then it's really an easy sentencing because [the victim] is here to tell you that restitution is not really an issue. He understands he will probably never get paid and he wants the defendant to go to prison.
Notwithstanding the prosecutor's comments, defense counsel continued to press the issue of restitution by questioning the *973 victim regarding the value of the generator. The prosecutor objected, saying the victim was not there for restitution. Instead, the victim wanted Lehmkuhle to serve time in prison. The trial court then told defense counsel that to warrant a downward departure, the prosecution would have to "tell me the need for restitution outweighs the need for incarceration" and "that comes from the victim and only the victim," and because that was not the case, he would have to assert some other basis to obtain a departure.[1] When it became clear that Lehmkuhle was not going to be able to ask for a downward departure in order to pay restitution, defense counsel stated:
Your Honor, that at this point if you're not willing to downward departure [sic] I'm moving to withdraw the plea based upon ineffective assistance of counsel.
I told Mr. Lehmkuhle I thought there was a strong possibility of him being downward departed since the need for restitution to the victim, especially the people of Haiti was so great. And we've heard that it is, but they still  but the victims in this case still want prison. I was ineffective. I'm asking to withdraw his plea today if you're unwilling to downward depart, Your Honor.
Without further discussion, the trial court denied the motion to withdraw the plea and immediately sentenced Lehmkuhle to a five-year prison term.
Florida Rule of Criminal Procedure 3.170(f) provides "the court may in its discretion, and shall on good cause," permit a guilty plea to be withdrawn at any time before sentencing. Under the rule, the trial court is obligated to allow the defendant to withdraw a plea as a matter of right if good cause is shown. Robinson v. State, 761 So.2d 269 (Fla.1999); Luedtke v. State, 6 So.3d 653, 655 (Fla. 2d DCA 2009). If less than good cause is shown, the court has the discretion to allow withdrawal of the plea. Taylor v. State, 870 So.2d 72 (Fla. 2d DCA 2003). Good cause to withdraw a plea has been found to exist when the defendant's plea was "infected by misapprehension, undue persuasion, ignorance, or was entered by one not competent to know its consequence or that it was otherwise involuntary, or that the ends of justice would be served by withdrawal of such plea." Onnestad v. State, 404 So.2d 403, 405 (Fla. 5th DCA 1981).
By stating that he had misadvised his client, defense counsel was attempting to demonstrate good cause to withdraw the plea. See Trenary v. State, 453 So.2d 1132, 1133-34 (Fla. 2d DCA 1984) ("The law is well settled that if a defendant enters a plea in reasonable reliance on his attorney's advice, which in turn was based on the attorney's honest mistake or misunderstanding, the defendant should be allowed to withdraw his plea."). However, the trial court prevented him from doing so by immediately denying the motion and sentencing Lehmkuhle. This case is similar to J.D.F. v. State, 870 So.2d 86 (Fla. 2d DCA 2003). J.D.F. entered negotiated pleas to two charges. At a separate disposition hearing, he orally moved to withdraw his pleas, stating counsel had misled him. The trial court immediately denied the motion, stating that J.D.F. could seek review of the issue on appeal. This court reversed, finding that "the trial court erred in immediately denying J.D.F.'s motion to withdraw his pleas without giving him an opportunity to present argument *974 and be heard." Id. at 87; see also Morales v. State, 973 So.2d 679, 681 (Fla. 2d DCA 2008) (holding that a defendant who orally moved to withdraw his plea at the beginning of sentencing should have been given an opportunity to present argument and be heard on his motion to withdraw plea before being sentenced). Likewise, the trial court here should have given Lehmkuhle an opportunity to be heard before ruling on his motion. Accordingly, we vacate Lehmkuhle's sentence and remand this case to the trial court to give Lehmkuhle a hearing on his motion to withdraw his guilty plea.
Reversed and remanded.
CASANUEVA, C.J., and ALTENBERND, J., Concur.
NOTES
[1]  Section 921.0026, Florida Statutes (2007), lists mitigating circumstances the trial court may properly consider when determining whether it should impose a downward departure sentence.
