Here's what Wikipedia says:
Involuntary commitment under the Baker Act requires that a judge, police officer, or doctor find that a person is mentally ill enough to require an involuntary medical exam. Those persons deemed by court to be a danger to themselves and others around them may be involuntarily committed.
Within 72 hours of examination, the person may be released or may consent to further inpatient treatment. If not, the facility that conducted the exam must file an involuntary commitment petition that must be heard by a court within five days.