Antacids function by chemically neutralizing gastric acid. When ingested, they react with hydrochloric acid in the stomach to form water and other neutral compounds. This reaction reduces acidity, thereby alleviating symptoms associated with excessive stomach acid. The onset of action is usually rapid, making them a popular choice for quick relief.