The cross section for the production of Zγ in proton-proton collisions at 8 TeV is measured based on data collected by the CMS experiment at the LHC corresponding to an integrated luminosity of 19.5 fb−1. Events with an oppositely-charged pair of muons or electrons together with an isolated photon are selected. The differential cross section as a function of the photon transverse momentum is measured inclusively and exclusively, where the exclusive selection applies a veto on central jets. The observed cross sections are compatible with the expectations of next-to-next-to-leading-order quantum chromodynamics. Limits on anomalous triple gauge couplings of ZZγ and Zγγ are set that improve on previous experimental results obtained with the charged lepton decay modes of the Z boson.