Materials can be made multifunctional by embedding them with living cells that perform sensing, synthesis, energy production, and physical movement. A challenge is that the conditions needed for living cells are not conducive to materials processing and require continuous water and nutrients. Here, we present a three dimensional (3D) printer that can mix material and cell streams to build 3D objects. Bacillus subtilis spores were printed within the material and germinated on its exterior surface, including spontaneously in new cracks. The material was resilient to extreme stresses, including desiccation, solvents, osmolarity, pH, ultraviolet light, and γ-radiation. Genetic engineering enabled the bacteria to respond to stimuli or produce chemicals on demand. As a demonstration, we printed custom-shaped hydrogels containing bacteria that can sense or kill Staphylococcus aureus, a causative agent of infections. This work demonstrates materials endued with living functions that can be used in applications that require storage or exposure to environmental stresses.