Aims. In nebular astrophysics, there has been a long-standing dichotomy in plasma diagnostics between abundance determinations using the traditional method based on collisionally excited lines (CELs), on the one hand, and (optical) recombination lines/continuum, on the other. A number of mechanisms have been proposed to explain the dichotomy. Deep spectroscopy and recombination line analysis of emission line nebulae (planetary nebulae and H ii regions) in the past decade have pointed to the existence of another previously unknown component of cold, H-deficient material as the culprit. Better constraints are needed on the physical conditions (electron temperature and density), chemical composition, mass, and spatial distribution of the postulated H-deficient inclusions in order to unravel their astrophysical origins. This requires knowledge of the relevant atomic parameters, most importantly the effective recombination coefficients of abundant heavy element ions such as C ii, O ii, N ii, and Ne ii, appropriate for the physical conditions prevailing in those cold inclusions (e.g. T e ≤ 1000 K). Methods. Here we report new ab initio calculations of the effective recombination coefficients for the N ii recombination spectrum. We have taken into account the density dependence of the coefficients arising from the relative populations of the fine-structure levels of the ground term of the recombining ion ( 2 P • 1/2 and 2 P • 3/2 in the case of N iii), an elaboration that has not been attempted before for this ion, and it opens up the possibility of electron density determination via recombination line analysis. Photoionization cross-sections, bound state energies, and the oscillator strengths of N ii with n ≤ 11 and l ≤ 4 have been obtained using the closecoupling R-matrix method in the intermediate coupling scheme. Photoionization data were computed that accurately map out the near-threshold resonances and were used to derive recombination coefficients, including radiative and dielectronic recombination. Also new is including the effects of dielectronic recombination via high-n resonances lying between the 2 P • 1/2 and 2 P • 3/2 levels. The new calculations are valid for temperatures down to an unprecedentedly low level (approximately 100 K). The newly calculated effective recombination coefficients allow us to construct plasma diagnostics based on the measured strengths of the N ii optical recombination lines (ORLs). Results. The derived effective recombination coefficients are fitted with analytic formulae as a function of electron temperature for different electron densities. The dependence of the emissivities of the strongest transitions of N ii on electron density and temperature is illustrated. Potential applications of the current data to electron density and temperature diagnostics for photoionized gaseous nebulae are discussed. We also present a method of determining electron temperature and density simultaneously.