Folding and function may impose different requirements on the amino acid sequences of proteins, thus potentially giving rise to conflict. Such a conflict, or frustration, can result in the formation of partially misfolded intermediates that can compromise folding and promote aggregation. We investigate this phenomenon by studying frataxin, a protein whose normal function is to facilitate the formation of iron-sulfur clusters but whose mutations are associated with Friedreich's ataxia. To characterize the folding pathway of this protein we carry out a Φ-value analysis and use the resulting structural information to determine the structure of the folding transition state, which we then validate by a second round of rationally designed mutagenesis. The analysis of the transition-state structure reveals that the regions involved in the folding process are highly aggregation-prone. By contrast, the regions that are functionally important are partially misfolded in the transition state but highly resistant to aggregation. Taken together, these results indicate that in frataxin the competition between folding and function creates the possibility of misfolding, and that to prevent aggregation the amino acid sequence of this protein is optimized to be highly resistant to aggregation in the regions involved in misfolding.