  We compute the two-loop electroweak corrections to the radiative decays of
the B meson in the SM. Electroweak effects reduce the Wilson coefficient
C_7^eff(mw) by 2.6% for a light Higgs boson of about 100 GeV and are less
important for a heavier Higgs. The leading term of a heavy top expansion of our
result differs from the one obtained in the gaugeless approximation where only
top quark Yukawa couplings are considered: we discuss the origin of the
discrepancy and provide a criterion for the validity of the gaugeless
approximation. As a byproduct of the calculation we also obtain the O(alpha)
corrections to the Wilson coefficient of the four-fermion operator Q_2. A
careful analysis of the interplay between electroweak and QCD effects leads to
an overall 2% reduction of the total branching ratio for B -> X_s gamma due to
purely electroweak corrections. For a light Higgs boson, the up-to-date SM
prediction is BR_gamma=3.29 10^-4.
