The choice of electrolyte has a crucial influence on the performance of rechargeable magnesium batteries. In multivalent electrolytes an agglomeration of ions to pairs or bigger clusters may affect the transport in the electrolyte and the reaction at the electrodes. In this work the formation of clusters is included in a general model for magnesium batteries. In this model, the effect of cluster formation on transport, thermodynamics and kinetics is consistently taken into account. The model is used to analyze the effect of ion clustering in magnesium tetrakis(hexafluoroisopropyloxy)borate in dimethoxyethane as electrolyte. It becomes apparent that ion agglomeration is able to explain experimentally observed phenomena at high salt concentrations.