High-temperature superconductivity in iron-arsenic materials (pnictides) near an antiferromagnetic phase raises the possibility of spin-fluctuation-mediated pairing. However, the interplay between antiferromagnetic fluctuations and superconductivity remains unclear in the underdoped regime, which is closer to the antiferromagnetic phase. Here we report that the superconducting gap of underdoped pnictides scales linearly with the transition temperature, and that a distinct pseudogap coexisting with the superconducting gap develops on underdoping. This pseudogap occurs on Fermi surface sheets connected by the antiferromagnetic wavevector, where the superconducting pairing is stronger as well, suggesting that antiferromagnetic fluctuations drive both the pseudogap and superconductivity. Interestingly, we found that the pseudogap and the spectral lineshape vary with the Fermi surface quasi-nesting conditions in a fashion that shares similarities with the nodal-antinodal dichotomous behaviour observed in underdoped copper oxide superconductors.