Underfitting occurs when a statistical model or machine learning algorithm fails to capture the underlying trend in the data. This typically happens when the model is too simple to represent the complexity of the data, resulting in poor predictive performance both on the training set and on unseen data.