A buffer is a substance that helps to maintain the pH of a solution by absorbing hydrogen ions (H+) or hydroxide ions (OH-) when they are added to the solution.