Nearly a quarter of genomic sequences and almost half of all receptors that are likely to be targets for drug design are integral membrane proteins. Understanding the detailed mechanisms of the folding of membrane proteins is a largely unsolved, key problem in structural biology. Here, we introduce a general model and use computer simulations to study the equilibrium properties and the folding kinetics of a C(alpha)-based two-helix bundle fragment (comprised of 66 aa) of bacteriorhodopsin. Various intermediates are identified and their free energy are calculated together with the free energy barrier between them. In 40% of folding trajectories, the folding rate is considerably increased by the presence of nonobligatory intermediates acting as traps. In all cases, a substantial portion of the helices is rapidly formed. This initial stage is followed by a long period of consolidation of the helices accompanied by their correct packing within the membrane. Our results provide the framework for understanding the variety of folding pathways of helical transmembrane proteins.