Appellant, Guy Gilliam, plead guilty to assault and battery of a high and aggravated nature. He now appeals from the denial of a motion to withdraw his plea. We reverse.
At the guilty plea proceeding, the solicitor informed the trial judge that he and the appellant’s attorney had agreed that in exchange for a recommendation to defer sentencing, appellant would leave South Carolina. Under the agreement, the appellant would only be sentenced if he returned to South Carolina. Initially, the trial judge sentenced appellant to one (1) year imprisonment, suspended, but after the solicitor again requested that he defer sentencing, the judge struck the imposed sentence and agreed to defer sentencing.
Appellant did not leave South Carolina and consequently was brought back before the trial judge for sentencing. At this time, appellant made a motion to withdraw his earlier plea of guilty. The trial judge denied the motion and, after reviewing appellant’s criminal record, imposed a sentence of nine (9) years imprisonment, suspended upon the service of three (3) years.
This Court held in State v. Baker, 58 S. C. 111, 36 S. E. 501 (1900), that a sentence banishing from the State a person convicted of a crime was beyond the power of a circuit judge. Such a sentence is impliedly prohibited by public policy. 21 Am. Jur. (2d) Criminal Lam § 609.
By agreeing to defer sentencing, the trial judge was in effect sanctioning an illegal banishment agreement.
It is a well established rule in this State that the granting of a motion to withdraw a guilty plea is a matter within the discretion of the trial judge before *326whom the plea is entered. State v. Cantrell, 250 S. C. 376, 158 S. E. (2d) 189 (1967); State v. Lambert, 266 S. C. 574, 225 S. E. (2d) 340 (1976)..However, a trial judge has no discretion to withhold a request for the withdrawal of a plea where the plea is conditioned on an invalid agreement. 21 Am. Jur. (2d) Criminal Law § 504.
As appellant’s guilty plea was obviously conditioned on an illegal banishment agreement, the trial judge should have allowed the appellant to withdraw his plea.
The case is remanded for the purpose of allowing the appellant to withdraw his guilty plea.
Reversed and remanded.