We present coplanar resonator measurements of the nonlinear microwave surface impedance of laser ablated and electron-beam coevaporated YBa2Cu3O7−δ thin films at 8 GHz in zero and applied magnetic fields, including the effects of irradiation with heavy ions. Correlations between the changes in surface resistance and reactance as a function of microwave current suggest that there are different contributions to the nonlinear behavior at low and high microwave currents in both zero and applied fields. In zero field, we suggest that microwave-induced flux lines are responsible for the observed nonlinear behavior, resulting in thermal runaway at large, sample dependent, microwave currents. The observed nonlinearity completely masks any possible contribution from the intrinsic pair breaking expected for a d-wave superconductor. In a magnetic field at relatively low currents, the nonlinearity can be described by the nonlinear dynamics of flux lines pinned by defects with a continuous range of pinning strengths. At higher currents, microwave field nucleation of flux lines is again considered important. On irradiation with 3.6 MeV/nucleon Xe-129 ions, the microwave losses and nonlinearity are significantly decreased in both zero and applied fields, which could have important implications for microwave device applications.