Correlations between environment and tree alpha-diversity in New Zealand's primary forests were examined using an extensive quantitative dataset (14 540 plots). Generalised additive models were used to examine relationships between species richness and temperature, solar radiation, root-zone moisture deficit, relative humidity, lithology, drainage, and plot size for all trees (112 species), and separately for broadleaved trees (88 species), conifers (17), and the genus Nothofagus (4). Diversity both for all tree species and for broadleaved trees was predicted to be highest on sites with high temperatures, high solar radiation, and high soil and atmospheric moisture, and on sedimentary and basaltic substrates. Highest conifer diversity was predicted on sites with intermediate temperatures, low solar radiation, high root-zone and atmospheric moisture, and rhyolitic and Quaternary substrates, particularly where drainage was impeded. Highest Nothofagus diversity was predicted for sites combining low temperatures, high solar radiation, high root-zone moisture but low atmospheric moisture, and on granitic substrates. Differences in diversity between the species groups on different lithologies are interpreted as rejecting both the effects of variation in large-scale disturbance histories, and the effects of confounding environmental factors associated with particular substrates. There were also significant interactions between species groups: both broadleaved tree and conifer richness were predicted to be lower on sites where one or more Nothofagus spp. — all of which have marked patchiness in their distribution — are present. Although these results are consistent with the hypothesis that tree diversity is highest on sites conducive to high productivity, history is also indicated as an important determinant of tree diversity in New Zealand.