The electrocardiogram (ECG) is an inexpensive and widely available diagnostic tool, and therefore has great potential to facilitate disease detection in large-scale populations. Both cardiac and noncardiac diseases may alter the appearance of the ECG, though the extent to which diseases across the human phenotypic landscape can be detected on the ECG remains unclear. We developed a deep learning variational autoencoder model that encodes and reconstructs ECG waveform data within a multidimensional latent space. We then systematically evaluated whether associations between ECG encodings and a broad range of disease phenotypes could be detected using the latent space model by deriving disease vectors and projecting individual ECG encodings onto the vectors. We developed models for both 12- and single-lead ECGs, akin to those used in wearable ECG technology. We leveraged phecodes to generate disease labels using International Classification of Disease (ICD) codes for about 1,600 phenotypes in three different datasets linked to electronic health record data. We tested associations between ECG encodings and disease phenotypes using a phenome-wide association study approach in each dataset, and meta-analyzed the results. We observed that the latent space ECG model identified associations for 645 (40%) diseases tested in the 12-lead model. Associations were enriched for diseases of the circulatory (n=140, 82% of category-specific diseases), respiratory (n=53, 62%), and endocrine/metabolic (n=73, 45%) systems, with additional associations evident across the human phenome; results were similar for the single-lead models. The top ECG latent space association was with hypertension in the 12-lead ECG model, and cardiomyopathy in the single-lead ECG model (p<2.2x10-308 for each). The ECG latent space model demonstrated a greater number of associations than ECG models using standard ECG intervals alone, and generally resulted in improvements in discrimination of diseases compared to models comprising only age, sex, and race. We further demonstrate how a latent space model can be used to generate disease-specific ECG waveforms and facilitate disease profiling for individual patients.