We constructed diagnostic diagrams using emission line ratios and equivalent widths observed in several samples of HII galaxies. The diagrams are compared to predictions from new photoionization models for evolving starbursts. We find that HII galaxies from objective-prism surveys are not reproduced by models of instantaneous starbursts surrounded by constant density, ionization bounded HII regions. The observed relations between emission line ratios and Hb equivalent width (W(Hb)) can be understood if older stellar populations are not negligible in HII galaxies. Also, different dust obscuration for stars and gas and leakage of Lyman continuum photons from the observed HII regions can be important. As a result, HII galaxies selected from objective-prism surveys are unlikely to contain many objects in which the most recent starburst is older than about 5~Myr. The observed increase of [OI]/Hb with decreasing W(Hb) can result from the dynamical effects of winds and supernovae. This interpretation provides also a natural explanation of the small range of ionization parameters in giant HII regions. The [OIII]/Hb vs [OII]/Hb diagnostic diagram cannot be fully understood in terms of pure photoionization models and indicate the need for additional heating sources. The [NII]/[OII] ratio is shown to increase as W(Hb) decreases. A possible explanation is an N/O increase due to gradual enrichment by winds from Wolf-Rayet stars on a time scale of 5 Myr. (abridged abstract)