Transcription factors control cell-specific gene expression programs through interactions with diverse coactivators and the transcription apparatus. Gene activation may involve DNA loop formation between enhancer-bound transcription factors and the transcription apparatus at the core promoter, but this process is not well understood. Here we report that mediator and cohesin physically and functionally connect the enhancers and core promoters of active genes in murine embryonic stem cells. Mediator, a transcriptional coactivator, forms a complex with cohesin, which can form rings that connect two DNA segments. The cohesin-loading factor Nipbl is associated with mediator-cohesin complexes, providing a means to load cohesin at promoters. DNA looping is observed between the enhancers and promoters occupied by mediator and cohesin. Mediator and cohesin co-occupy different promoters in different cells, thus generating cell-type-specific DNA loops linked to the gene expression program of each cell.