Imaging polarimetry of Uranus and Neptune in the R, i, and z bands are presented. In all observations a radial limb polarization on the order of 1% was detected with a position angle perpendicular to the limb. The polarization is higher in both planets for the shorter wavelength bands. As a first approximation, the polarization seems to be equally strong along the entire limb. This is unlike Jupiter and Saturn, where significant limb polarization is only observed at the poles. We determined flux-weighted averages of the limb polarization and radial limb polarization profiles, and investigated the degradation and cancellation effects in the polarization signal due to the seeing-limited spatial resolution of our observations. Taking this into account we derived corrected values for the limb polarization in Uranus and Neptune. The results are compared with analytic models for Rayleigh scattering atmospheres for the semi-infinite case and finite layers with ground albedo. The comparison shows that the detected polarization is compatible with expectations. This indicates that limb-polarization measurements offer a powerful diagnostic tool for investigating the properties of scattering particles in the upper atmospheres of Uranus and Neptune, in particular if more sophisticated numerical modeling of the limb polarization becomes available. It is also concluded from the overall strength of the limb polarization that the disk-integrated polarization of Uranus and Neptune for large phase angles is high (p > 20%). This is of interest for future polarimetric detections of extra-solar planets with atmospheric properties similar to Uranus and Neptune.