We have calculated the opacities and secondary production mechanisms of high energy photons arising in gamma-ray burst internal shocks, using exact cross-sections for the relevant processes. We find that for reasonable choices of parameters, photons in the range of 10's to 100's of GeV may be emitted in the prompt phase. Photons above this range are subject to electron-positron pair production with fireball photons and would be absent from the spectrum escaping the gamma-ray burst. We find that, in such cases, the fireball becomes optically thin again at ultra-high energies ($\gtrsim$ PeV). On the other hand, for sufficiently large fireball bulk Lorentz factors, the fireball is optically thin at all energies. Both for $\gamma\gamma$ self-absorbed and optically thin cases, the escaping high energy photons can interact with infra-red and microwave background photons to produce delayed secondary photons in the GeV-TeV range. These may be observable with GLAST, or at low redshifts with ground-based air Cherenkov telescopes. Detection of the primary prompt spectrum constrains the bulk Lorentz factor, while detection of delayed secondary gamma-rays would provide a consistency check for the primary spectrum and the bulk Lorentz factor as well as constraints on the intergalactic magnetic field strength.