Despite broad scientific interest in harnessing the power of Earth's microbiomes, knowledge gaps hinder their efficient use for addressing urgent societal and environmental challenges. We argue that structuring research and technology developments around a design-build-test-learn (DBTL) cycle will advance microbiome engineering and spur new discoveries of the basic scientific principles governing microbiome function. In this Review, we present key elements of an iterative DBTL cycle for microbiome engineering, focusing on generalizable approaches, including top-down and bottom-up design processes, synthetic and self-assembled construction methods, and emerging tools to analyse microbiome function. These approaches can be used to harness microbiomes for broad applications related to medicine, agriculture, energy and the environment. We also discuss key challenges and opportunities of each approach and synthesize them into best practice guidelines for engineering microbiomes. We anticipate that adoption of a DBTL framework will rapidly advance microbiome-based biotechnologies aimed at improving human and animal health, agriculture and enabling the bioeconomy.