A quadratic Leibniz algebra $(\mathbb{V},[\ifmmode\cdot\else\textperiodcentered\fi{},\ifmmode\cdot\else\textperiodcentered\fi{}],\ensuremath{\kappa})$ gives rise to a canonical Yang-Mills type functional $S$ over every space-time manifold. The gauge fields consist of 1-forms $A$ taking values in $\mathbb{V}$ and 2-forms $B$ with values in the subspace $\mathbb{W}\ensuremath{\subset}\mathbb{V}$ generated by the symmetric part of the bracket. If the Leibniz bracket is antisymmetric, the quadratic Leibniz algebra reduces to a quadratic Lie algebra, $B\ensuremath{\equiv}0$, and $S$ becomes identical to the usual Yang-Mills action functional. We describe this gauge theory for a general quadratic Leibniz algebra. We then prove its (classical and quantum) equivalence to a Yang-Mills theory for the Lie algebra $\mathfrak{g}=\mathbb{V}/\mathbb{W}$ to which one couples massive 2-form fields living in a $\mathfrak{g}$-representation. Since in the original formulation the $B$-fields have their own gauge symmetry, this equivalence can be used as an elegant mass-generating mechanism for 2-form gauge fields, thus providing a ``higher Higgs mechanism'' for those fields.