
630 So.2d 1229 (1994)
Eric Eugene VICKERS, Appellant,
v.
STATE of Florida, Appellee.
No. 93-04015.
District Court of Appeal of Florida, Second District.
January 26, 1994.
*1230 PER CURIAM.
Eric Eugene Vickers appeals the denial of his motion to correct illegal sentence in which he asserts he was improperly sentenced to thirty years' imprisonment for a second degree felony. We agree that the sentence is illegal.
Originally, Vickers was charged with first degree murder and robbery. In a negotiated agreement, Vickers pled guilty to the lesser charge of third degree murder with a firearm; the armed robbery charge was nolle prossed. The agreed term of imprisonment was thirty years with a three year minimum mandatory.
Vickers correctly argues that the sentence is illegal because a conviction for third degree murder is a second degree felony for which the maximum penalty cannot exceed fifteen years' incarceration.
The trial court denied the motion to correct the sentence, finding that the sentence was properly enhanced because a firearm was used in the murder. The holding is based upon the fact that the supreme court did not decide Gonzalez v. State, 585 So.2d 932 (Fla. 1991)[1] until seventeen months after the sentence was imposed in this case. The court indicated that the supreme court ruling should not be applied retroactively.
The trial court's reliance upon the timing of the issuance of Gonzalez is misplaced. Prior to the date sentence was imposed, this court and other courts have held that a sentence cannot be enhanced for the use of a weapon when its use is an essential element of the crime charged. See Franklin v. State, 541 So.2d 1227 (Fla.2d DCA 1989), approved, Gonzalez v. State, 585 So.2d 932 (Fla. 1991); Cherry v. State, 540 So.2d 146 (Fla. 4th DCA 1989); Pinkerton v. State, 534 So.2d 425 (Fla. 5th DCA 1988); Stinson v. State, 520 So.2d 680 (Fla. 1st DCA 1988).
A defendant cannot agree to an illegal sentence, therefore, we reverse and remand for the court to resentence Vickers within the fifteen year maximum sentence range or allow him to withdraw his plea and to proceed accordingly.
SCHOONOVER, A.C.J., and PATTERSON and ALTENBERND, JJ., concur.
NOTES
[1]  In Gonzalez, the supreme court ruled that the use of a firearm is an essential element of the offense of third degree murder with a firearm and that the sentence could not be enhanced due to the use of a firearm.
