Pickling preserves food through the process of fermentation or by using a vinegar solution. In fermentation, beneficial bacteria convert sugars into lactic acid, creating an acidic environment that inhibits the growth of harmful bacteria. Vinegar, on the other hand, creates an acidic environment directly, preventing spoilage.