Aims. We present deep spectrophotometry for a sample of 8 planetary nebulae (PNe) and 12 HII regions distributed throughout the dwarf irregular galaxy NGC 3109, in order to analyze the chemical composition of both types of nebulae. Methods. We describe the observations and data reduction, and present line intensities for the nebular emission lines detected. The physical conditions and the abundances of He, O, Ne, N, S and Ar are derived, using the classical T e -based method. We confirm our previous identification of PNe and HII regions based on photometry, except for one object, which we argue is a compact HII region rather than a planetary nebula. Results. We find that the chemical composition of the interstellar medium in NGC 3109, as sampled by its HII regions, is remarkably uniform. The oxygen abundance is log O/H + 12 = 7.77 ± 0.07 in this galaxy, as compared to 8.05 ± 0.09 for the Small Magellanic Cloud (for which we rederived the metallicity in a homogeneous way). PNe show significantly higher oxygen abundances in NGC 3109: log O/H + 12 = 8.16 ± 0.19. Similarly to what has been suggested for some of the PNe in the Magellanic Clouds and other metal-poor galaxies, we argue that oxygen in the PNe in NGC 3109 is affected by dredge up in their progenitors. This could also be the case for neon, although the uncertainties for this element are bigger. Conclusions. From our analysis, we conclude that oxygen and neon are not always a safe indicator of the chemical composition of the interstellar medium at low metallicities. An alternative to the O and Ne enrichment in PNe is that the low metallicity in HII regions has been caused by dilution of the interstellar medium due to an interaction with a neighboring galaxy about a Gyr ago. The excitation patterns of the PNe in NGC 3109 are very different from the excitation patterns of PNe in other galaxies. This issue needs to be investigated further, as it implies that the evolution of PNe depends upon the properties of their progenitor stellar populations, which vary from galaxy to galaxy. This should affect the planetary nebula luminosity function and its use as a distance indicator. Regarding individual objects, we find that the planetary nebula named PN 14 shows clear Wolf-Rayet features, very low excitation and high density. Thus, it is similar to some of the galactic PNe ionized by late [WC] stars.