Section 348
Safe custody of person acquitted
Whenever the finding states that the accused person committed the act alleged, the Court before which the trial has been held shall, if that act would, but for incapacity found, have constituted an offence, order that person to be kept in safe custody in such place and manner as the Court thinks fit and shall report the case for the orders of the Ruler of the State in which the trial is held:
Provided that if the Court concerned is a Magistrate’s Court, the
Magistrate may in his discretion, if he considers that the offence charged is not of a serious nature and that that person can safely be released without danger of his doing injury to himself or any other person, caution and discharge him.
(2)
The Ruler may order that person to be confined in a psychiatric hospital during the pleasure of the Ruler of the State.
Criminal Procedure Code 191