Our goal was to assess the effects of environmental enrichment during gestation on the hypothalamic-pituitary-adrenal axis (HPA) and behavior of offspring. In order to test our hypothesis, we kept 18 sows (Sus scrofa domesticus) in straw during the final third of gestation (from 90 to 114 days) and 18 sows without straw (control). On the piglets born (one pair per sow), we performed an analysis of behavior, cortisol levels in saliva and performed fear tests to assess resilience, emotional reactivity, responsiveness to stressors, and cognition. The environmental enrichment used during gestation reduced aggressiveness (p < 0.02) and nosing in piglets (p < 0.08). In addition, salivary cortisol was higher in piglets from sows in barren environments (p < 0.03). Salivary cortisol was higher in piglets from sows in environmentally enriched conditions only on the day of weaning (p < 0.00001). There was no difference in the piglets' emotionality when we compared groups with both sexes together. However, there was a sex-specific difference, in which females born from sows kept with environmental enrichment explored more (novel object exploration, p= 0.02; time pushing the object, p= 0.03) and showed less fear at the novel object test. Environmental enrichment in the end of gestation influenced the offspring's HPA-axis activity and behavior, improving their welfare.