Using the exclusive decay BJ/(µ+µ-)(K+K-), we report the most precise single measurement of the B lifetime. The data sample corresponds to an integrated luminosity of approximately 220 pb-1 collected with the D0 detector at the Fermilab Tevatron Collider in 2002–2004. We reconstruct 337 signal candidates, from which we extract the B lifetime, (B)=1.444(stat)±0.020(sys) ps. We also report a measurement for the lifetime of the B0 meson using the exclusive decay B0J/(µ+µ-)K*0(892)(K+-). We reconstruct 1370 signal candidates, obtaining (B0)=1.473(stat)±0.023(sys) ps, and the ratio of lifetimes, (B)/(B0)=0.980(stat)±0.003(sys).