The folding and stabilization of a-helical transmembrane proteins are still not well understood. Following cofactor binding to a membrane protein provides a convenient method to monitor the formation of appropriate native structures. We have analyzed the assembly and stability of the transmembrane cytochrome b(559)', which can be efficiently assembled in vitro from a heme-binding PsbF homo-dimer by combining free heme with the apo-cytochrome b(559)'. Unfolding of the protein dissolved in the mild detergent dodecyl maltoside may be induced by addition of SDS, which at high concentrations leads to dimer dissociation. Surprisingly, absorption spectroscopy reveals that heme binding and cytochrome formation at pH 8.0 are optimal at intermediate SDS concentrations. Stopped-flow kinetics revealed that genuine conformational changes are involved in heme binding at these SDS concentrations. GPS (Global Protein folding State mapping) NMR measurements showed that optimal heme binding is intimately related to a change in the degree of histidine protonation. In the absence of SDS, the pH curve for heme binding is bell-shaped with an optimum at around pH 6-7. At alkaline pH values, the negative electrostatic potential of SDS lowers the local pH sufficiently to restore efficient heme binding, provided the amount of SDS needed for this does not denature the protein. Accordingly, the higher the pH value above 6-7, the more SDS is needed to improve heme binding, and this competes with the inherent tendency of SDS to dissociate cytochrome b(559)'. Our work highlights that, in addition to its denaturing properties, SDS can affect protein functions by lowering the local pH.