A study of proton-proton collisions in which two b hadrons are produced in association with a Z boson is reported. The collisions were recorded at a centre-of-mass energy of 7 TeVwith the CMS detector at the LHC, for an integrated luminosity of 5.2 fb−1. The b hadrons are identified by means of displaced secondary vertices, without the use of reconstructed jets, permitting the study of b-hadron pair production at small angular separation. Differential cross sections are presented as a function of the angular separation of the b hadrons and the Z boson. In addition, inclusive measurements are presented. For both the inclusive and differential studies, different ranges of Z boson momentum are considered, and each measurement is compared to the predictions from different event generators at leading-order and next-to-leading-order accuracy.