Many bacterial species possess long filamentous structures known as pili or fimbriae extending from their surfaces. Despite the diversity in pilus structure and biogenesis, pili in Gram-negative bacteria are typically formed by non-covalent homopolymerization of major pilus subunit proteins (pilins), which generates the pilus shaft. Additional pilins may be added to the fiber and often function as host cell adhesins. Some pili are also involved in biofilm formation, phage transduction, DNA uptake and a special form of bacterial cell movement, known as 'twitching motility'. In contrast, the more recently discovered pili in Gram-positive bacteria are formed by covalent polymerization of pilin subunits in a process that requires a dedicated sortase enzyme. Minor pilins are added to the fiber and play a major role in host cell colonization.This review gives an overview of the structure, assembly and function of the best-characterized pili of both Gram-negative and Gram-positive bacteria.