A search is performed for narrow resonances decaying to final states of two jets, with at least one jet originating from a b quark, in proton-proton collisions at s = 13 TeV . The data set corresponds to an integrated luminosity of 138 fb - 1 collected with the CMS detector at the LHC. Jets originating from energetic b hadrons are identified through a b -tagging algorithm that utilizes a deep neural network or the presence of a muon inside a jet. The invariant mass spectrum of jet pairs is well described by a smooth parametrization and no evidence for the production of new particles is observed. Upper limits on the production cross section are set for excited b quarks and other resonances decaying to dijet final states containing b quarks. These limits exclude at 95% confidence level models of Z ′ bosons with masses from 1.8 TeV to 2.4 TeV and of excited b quarks with masses from 1.8 TeV to 4.0 TeV. This is the most stringent exclusion of excited b quarks to date.