Prompt and delayed high-energy emission from cosmological gamma-ray bursts