  We compute the complete two-loop O(alpha) Wilson coefficients relevant for
radiative decays of the B meson in the SM. This is a necessary step in the
calculation of the O(alpha alpha_s^n ln^n m_b/M_W) corrections and improves on
our previous analysis of electroweak effects in B -> X_s gamma. We describe in
detail several interesting technical aspects of the calculation and include all
dominant QED matrix elements. In our final result, we neglect only terms
originated from the unknown O(alpha alpha_s) evolution of the Wilson
coefficients and some suppressed two-loop matrix elements. Due to the
compensation among different effects, we find that non-trivial electroweak
corrections decrease the branching ratio by about 3.6% for a light Higgs boson,
very close to our previous result. The corresponding up-to-date SM prediction
for the branching ratio with E_gamma > 1.6 GeV is (3.61 +- 0.30) x 10^-4.
