We present detailed calculations of the prompt spectrum of gamma-ray bursts (GRBs) predicted within the fireball model framework, in which emission is due to internal shocks in an expanding relativistic wind. Our time-dependent numerical model describes cyclo-synchrotron emission and absorption, inverse and direct Compton scattering, and e(+/-) pair production and annihilation ( including the evolution of high-energy electromagnetic cascades). It allows, in particular, a self-consistent calculation of the energy distribution of e(+/-) pairs produced by photon annihilation and hence, a calculation of the spectra resulting when the scattering optical depth due to pairs, tau(+/-), is high. We show that emission peaks at similar to1 MeV for moderate-to-large tau(+/-), reaching tau(+/-)similar to10(2). In this regime of large compactness we find that ( 1) a large fraction of shock energy can escape as radiation even for large tau(+/-); (2) the spectrum depends only weakly on the magnetic field energy fraction; ( 3) the spectrum is hard, epsilon(2) dN/depsilon proportional to epsilon(alpha) with 0.5 < alpha < 1, between the self-absorption (epsilon(ssa) = 10(0.5+/-0.5) keV) and peak (epsilon(peak) = 10(0.5+/-0.5) MeV) photon energy; (4) the spectrum shows a sharp cutoff at similar to10 MeV; and (5) thermal Comptonization leads to emission peaking at epsilon(peak) greater than or similar to 30 MeV and cannot, therefore, account for observed GRB spectra. For small compactness, spectra extend to higher than 10 GeV with flux detectable by GLAST, and the spectrum at low energy depends on the magnetic field energy fraction. Comparison of the flux at similar to1 GeV and similar to100 keV may therefore allow the determination of the magnetic field strength. For both small and large compactness, the spectra depend only weakly on the spectral index of the energy distribution of accelerated electrons.