In massive primordial galaxies, the gas may directly collapse and form a single central massive object if cooling is suppressed. H2 line cooling can be suppressed in the presence of a strong soft-ultraviolet radiation field, but the role played by other cooling mechanisms is less clear. In optically thin gas, Lyα cooling can be very effective, maintaining the gas temperature below 104 K over many orders of magnitude in density. However, the large neutral hydrogen column densities present in primordial galaxies render them highly optically thick to Lyα photons. In this paper, we examine in detail the effects of the trapping of these Lyα photons on the thermal and chemical evolution of the gas. We show that despite the high optical depth in the Lyman series lines, cooling is not strongly suppressed, and proceeds via other atomic hydrogen transitions. At densities larger than ∼109 cm−3, collisional dissociation of molecular hydrogen becomes the dominant cooling process and decreases the gas temperature to about 5000 K. The gas temperature evolves with density as , with γeff = 0.97–0.98. The evolution is thus very close to isothermal, and so fragmentation is possible, but unlikely to occur during the initial collapse. However, after the formation of a massive central object, we expect that later-infalling, higher angular momentum material will form an accretion disk that may be unstable to fragmentation, which may give rise to star formation with a top-heavy initial mass function.