If a defendant is committed to the state hospital for the reason that he is insane or mentally defective to the extent that he is unable to understand the proceedings against him or to assist in his defense, if charged with a crime, or for the reason that he is found insane after conviction and prior to pronouncing sentence, he shall be detained in the state hospital until he becomes sane. When the defendant becomes sane, the superintendent of the state hospital shall give notice of that fact to the sheriff and county attorney of the county. The sheriff shall thereupon, without delay, bring the defendant from the state hospital and place him in proper custody, until he is brought to trial or sentenced, or is legally discharged.
A.R.S. § 13-4519