Apical constriction driven by actin and non-muscle myosin II (actomyosin) provides a well-conserved mechanism to mediate epithelial folding. It remains unclear how contractile forces near the apical surface of a cell sheet drive out-of-the-plane bending of the sheet and whether myosin contractility is required throughout folding. By optogenetic-mediated acute inhibition of actomyosin, we find that during Drosophila mesoderm invagination, actomyosin contractility is critical to prevent tissue relaxation during the early, 'priming' stage of folding but is dispensable for the actual folding step after the tissue passes through a stereotyped transitional configuration. This binary response suggests that Drosophila mesoderm is mechanically bistable during gastrulation. Computer modeling analysis demonstrates that the binary tissue response to actomyosin inhibition can be recapitulated in the simulated epithelium that undergoes buckling-like deformation jointly mediated by apical constriction in the mesoderm and in-plane compression generated by apicobasal shrinkage of the surrounding ectoderm. Interestingly, comparison between wild-type and snail mutants that fail to specify the mesoderm demonstrates that the lateral ectoderm undergoes apicobasal shrinkage during gastrulation independently of mesoderm invagination. We propose that Drosophila mesoderm invagination is achieved through an interplay between local apical constriction and mechanical bistability of the epithelium that facilitates epithelial buckling.