The spectral properties of solar radio spikes are believed to be tightly related to the spike source inhomogeneity: in particular, the spikes display a rather large scatter of spectral bandwidth of the emission lines both within one event and from one event to another. This paper studies the effect of random magnetic and density inhomogeneities on the spectral properties of the electron cyclotron maser emission produced by superthermal electrons, which is likely responsible for solar radio spikes. Magnetic irregularities with a broad distribution over spatial scales are shown to provide considerable spectral broadening that is not necessarily small compared to the natural bandwidth, even for small magnetic inhomogeneities. The developed renormalization scheme allows us to describe quantitatively the spectral shape of the emission line when the broadening is large. Moreover, the presence of stronger magnetic inhomogeneities gives rise to the splitting of the emission line into two peaks, in agreement with the observed noninteger harmonic ratio between spectrally separated spike bands. Typical values of the spectral bandwidth are found to be fairly consistent with spike observations. The developed theory suggests new possibilities for random magnetic field diagnostics. The estimated magnitudes of the random magnetic field at the spike source look rather reasonable.