Ab initio CASSCF (complete active space SCF) and valence CI calculations have been performed for the lowest electronic states of HN3. The potential energy curves of the five lowest singlet and the five lowest triplet valence states of HN3 along the interior N-N distance R show that only the lowest excited singlet state, 1(1)A'', is involved in the UV photodissociation of HN3 at long wavelengths (lambda > 220 nm). The photodissociation products are exclusively N2(X1-SIGMA-g+) and NH(a1-DELTA). At shorter wavelengths several higher excited states of HN3 can also be involved; this makes the photodissociation process very complex and leads to the production of NH in several different electronic states. Large parts of the potential energy surface of the 1(1)A'' state have been calculated, in particular in the Franck-Condon region. The dependence of this surface on the N2-NH distance R and the various valence angles is used to explain the experimentally observed rotational state distributions of the photodissociation fragments N2 and NH(a).