Context. Gamma-ray bursts (GRB) are the most powerful events in the universe. They are capable of accelerating particles to very high energies, so are strong candidates as sources of detectable astrophysical neutrinos. Aims. We study the effects of particle acceleration and escape by implementing a two-zone model in order to assess the production of high-energy neutrinos in GRBs associated with their prompt emission. Methods. Both primary relativistic electrons and protons are injected in a zone where an acceleration mechanism operates and dominates over the losses. The escaping particles are re-injected in a cooling zone that propagates downstream. The synchrotron photons emitted by the accelerated electrons are taken as targets for pγ interactions, which generate pions along with the pp collisions with cold protons in the flow. The distribution of these secondary pions and the decaying muons are also computed in both zones, from which the neutrino output is obtained. Results. We find that for escape rates lower than the acceleration rate, the synchrotron emission from electrons in the acceleration zone can account for the GRB emission, and the production of neutrinos via pγ interactions in this zone becomes dominant for E ν > 10 5 GeV. For illustration, we compute the corresponding diffuse neutrino flux under different assumptions and show that it can reach the level of the signal recently detected by IceCube.