Spores are formed through a process called sporulation. This process is typically initiated when the parent organism encounters stressful conditions, such as nutrient deprivation or extreme temperatures. Sporulation allows the organism to enter a dormant state, enhancing its ability to endure harsh environments until conditions improve.