DFT and TD-DFT calculations in the gas phase and water have been performed for both anionic and zwitterionic forms of urocanic acid (UA) to gain an insight into the origin of its wavelength-dependent E/Z photoisomerization. Theoretical examination of the rotational flexibility of the carboxylic acid group by the B3LYP/6-31+G(d,p) method in conjunction with the COSMO solvent model supports the earlier suggestion (Danielsson, J.; Soderhall, J. A.; Laaksonen, A. Mol. Phys. 2002, 100, 1873) that in aqueous solution the carboxylic acid group may rotate. Our TD-B3LYP results on vertical excitation energies for the different CCCOO- rotamers of zwitterionic UA indicate that deviation from planarity may lead to an alteration of the excited-state order. We suggest two possible singlet/triplet conical intersections (S2/T5 and S1/T3) located around 306 and 314 nm. A mechanistic discussion and simplified Jablonski-type diagrams are presented for three spectral regions where UA exhibits different photobehavior: (i) before S2/T5 (λ < 306 nm), (ii) between two, S2/T5 and S1/T3, intersections (306 nm < λ < 314 nm), and (iii) after S1/T3 (UV-A irradiation at λ > 314 nm). E/Z photoisomerization occurs in the narrow spectral region ii on the nπ* singlet excited surface. The comparison of molecular orbitals and an effective electronic potential analysis of anionic UA forms suggest that the excited state of parent N-anionic UA undergoes proton photoattachment, whereas T-anionic UA does not change its protonation state upon becoming excited. It is suggested that the formation of zwitterionic species from excited N-anionic UA is responsible for a similar photochemical behavior at different pH values (5.0 and 7.0) under the photostationary irradiation. The presence of the second tautomeric component can be one of the reasons for the slight differences for zwitterionic and anionic UA solutions observed experimentally in the transient absorption dynamics and fluorescence spectra.