Polyglutamine expansion at the N-terminus of the huntingtin protein exon 1 (Htt-ex1) is closely associated with a number of neurodegenerative diseases, which result from the aggregation of the increased polyQ repeat. However, the underlying structures and aggregation mechanism are still poorly understood. We performed microsecond-long all-atom molecular dynamics simulations to study the folding and dimerization of Htt-ex1 (about 100 residues) with non-pathogenic and pathogenic polyQ lengths, and uncovered substantial differences. The non-pathogenic monomer adopts a long α-helix that includes most of the polyQ residues, which forms the interaction interface for dimerization, and a PPII-turn-PPII motif in the proline-rich region. In the pathogenic monomer, the polyQ region is disordered, leading to compact structures with many intra-protein interactions and the formation of short β-sheets. Dimerization can proceed via different modes, where those involving the N-terminal headpiece bury more hydrophobic residues and are thus more stable. Moreover, in the pathogenic Htt-ex1 dimers the proline-rich region interacts with the polyQ region, which slows the formation of β-sheets.