The rotational spectrum of cyanic acid, HOCN, has been detected in the centimeter-wave band in a molecular beam by Fourier transform microwave spectroscopy and in the millimeter-wave band by conventional spectroscopy in a low-pressure laboratory discharge. Spectroscopic constants, including the nitrogen hyperfine coupling constant, derived from 31 a-type transitions between 21 and 360 GHz with J up to 17 and K-a <= 2 allow the spectrum in the only rotational ladders populated in the interstellar gas to be calculated well into the submillimeter-wave band to 1 km s(-1) or better in equivalent radial velocity. Four consecutive transitions of HOCN between 83.9 and 146.8 GHz were tentatively identified in published spectral line surveys of Sgr B2(OH). An approximate column density in Sgr B2(OH) of 6 x 10(12) cm(-2) implies that the HOCN/HNCO ratio is about 0.5%. Because HNCO is widely distributed in the interstellar gas, HOCN may be as well.