The chemical reactions and pathways involving membrane lipids, any lipid found in or associated with a biological membrane.