N-grams are contiguous sequences of n items from a given sample of text or speech, used in natural language processing to predict the next item in a sequence or to analyze text patterns. They are fundamental in building language models, aiding in tasks like text classification, machine translation, and speech recognition.