Any court having jurisdiction of actions for divorce, or for nullity of marriage or of separate support or maintenance, may, upon commencement of such action and during the pendency thereof, order the husband or wife to vacate forthwith the marital home for a period of time not exceeding ninety days, and upon further motion for such additional certain period of time, as the court deems necessary or appropriate if the court finds, after a hearing, that the health, safety or welfare of the moving party or any minor children residing with the parties would be endangered or substantially impaired by a failure to enter such an order. The opposing party shall be given at least three days' notice of such hearing and may appear and be heard either in person or by his attorney. If the moving party demonstrates a substantial likelihood of immediate danger to his or her health, safety or welfare or to that of such minor children from the opposing party, the court may enter a temporary order without notice, and shall immediately thereafter notify said opposing party and give him or her an opportunity to be heard as soon as possible but not later than five days after such order is entered on the question of continuing such temporary order. The court may issue an order to vacate although the opposing party does not reside in the marital home at the time of its issuance, or if the moving party has left such home and has not returned there because of fear for his or her safety or for that of any minor children.
Mass. Gen. Laws ch. 208, § 34B