The chemical reactions and pathways involving glyphosate, a broad-spectrum herbicide also known by the trade name Roundup. It is a member of a broad class of compounds known as phosphonic acids, which contain a direct carbon-to-phosphorus (C-P) bond.