Bacillus subtilis mutants lacking ymdB are unable to form biofilms, exhibit a strong overexpression of the flagellin gene hag, and are deficient in SlrR, a SinR antagonist. Here, we report the functional and structural characterization of YmdB, and we find that YmdB is a phosphodiesterase with activity against 2',3'- and 3',5'-cyclic nucleotide monophosphates. The structure of YmdB reveals that the enzyme adopts a conserved phosphodiesterase fold with a binuclear metal center. Mutagenesis of a catalytically crucial residue demonstrates that the enzymatic activity of YmdB is essential for biofilm formation. The deletion of ymdB affects the expression of more than 800 genes; the levels of the σD-dependent motility regulon and several sporulation genes are increased, and the levels of the SinR-repressed biofilm genes are decreased, confirming the role of YmdB in regulating late adaptive responses of B. subtilis.