How it works
Instead of using a single train/test split, cross-validation divides the dataset into k parts, or folds. The model trains on k-1 parts and is tested on the remaining part; the process repeats k times, each time with a different part held out for testing. The average of the results gives a more reliable estimate of real performance. The most common variant is k-fold, but there are others, such as leave-one-out.
Practical example
With 1000 examples and k=5, each fold has 200 examples. The model is trained 5 times, tested on 200 different examples each time, and the final accuracy is the average of the 5 rounds. This reduces the impact of an unlucky split and brings the evaluation closer to what you would see on a final test set.
What it's for
It reduces the risk of a lucky or unlucky data split giving a false impression of quality. It is a standard practice for comparing models and tuning hyperparameters honestly, especially with small or medium sized datasets.
Limitations
Cross-validation does not replace a final untouched test set. It helps detect overfitting, but regularization and final evaluation are still needed to ensure generalization in production.