When wine ferments, the yeasts convert the sugars in the grapes into carbon dioxide, or CO2, and alcohol. Most of this gas is released before bottling. 

Sometimes, winemakers cause a secondary fermentation in the bottle or in a controlled tank. This creates the bubbles in champagne, cava, and other sparkling wines.