We report on the search for spectral irregularities induced by oscillations between photons and axionlike-particles (ALPs) in the γ-ray spectrum of NGC 1275, the central galaxy of the Perseus cluster. Using 6 years of Fermi Large Area Telescope data, we find no evidence for ALPs and exclude couplings above 5×10^{-12} GeV^{-1} for ALP masses 0.5≲m_{a}≲5 neV at 95% confidence. The limits are competitive with the sensitivity of planned laboratory experiments, and, together with other bounds, strongly constrain the possibility that ALPs can reduce the γ-ray opacity of the Universe.