Objectives were to determine effects of lactation and pregnancy on endometrial gene expression on d 17 of the estrous cycle and pregnancy. Heifers (n = 33) were assigned randomly after parturition to lactating (L, n = 17) or nonlactating (NL, n = 16) groups. Cows were subjected to an ovulation synchronization program for a timed artificial insemination (TAI); 10 cows in L and 12 in NL were inseminated. Slaughter occurred 17 d after the day equivalent to TAI, and intercaruncular endometrial tissues were collected. Gene expression was determined by DNA microarray analysis for pregnant (L, n = 8; NL, n = 6) and noninseminated cyclic (L, n = 7; NL, n = 4) cows. Differentially expressed genes were selected with a P-value <0.01 and absolute expression >40. In addition, a fold effect >1.5 was used as a criterion for genes affected by pregnancy. In total, 210 genes were differentially regulated by lactation (136 downregulated and 74 upregulated), and 702 genes were differentially regulated by pregnancy (407 downregulated and 295 upregulated). The interaction effect of pregnancy and lactation affected 61 genes. Genes up- and downregulated in pregnant cows were associated with several gene ontology terms, such as defense response and interferon regulatory factor, cell adhesion, and extracellular matrix. The gene ontology analyses of up- and downregulated genes of lactating cows revealed terms related to immunoglobulin-like fold, immune response, COMM domain, and non-membrane-bounded organelle. Several genes upregulated by lactation, such as IGHG1, IGLL1, IGK, and TRD, were related to immune function, particularly for B cells and γδ T cells. Developmental genes related to limb and neural development and glucose homeostasis (e.g., DKK1, RELN, PDK4) were downregulated by lactation, whereas an interaction was also detected for RELN. The stated genes associated with immune function and developmental genes expressed in the endometrium affected by lactational state are possible candidate genes for interventions to improve fertility of lactating dairy cows.