Adherence of bacteria to eukaryotic cells is essential for the initiation of infection in many animal and human pathogens, e.g. Neisseria gonorrhoeae and Pseudomonas aeruginosa. Adhesion-mediating type IV pili, filamentous surface appendages formed by pilin subunits, are crucial virulence factors. Here, we report that type IV pilus-dependent adhesion is also involved in plant-bacteria and fungus-bacteria interactions. Nitrogen-fixing, endophytic bacteria, Azoarcus sp., can infect the roots of rice and spread systemically into the shoot without causing symptoms of plant disease. Formation of pili on solid media was dependent on the pilAB locus. PilA encodes an unusually short (6.4 kDa) putative pilin precursor showing 100% homology to the conserved N-terminus of the Pseudomonas aeruginosa type IV pilin. PilB encodes for a 14.2 kDa polypeptide showing similarity to FimF, a component of type I fimbriae of Escherichia coli. It was found to be extruded beyond the cell surface by immunofluorescence studies, and it may, therefore, be part of a pilus assembly complex or the pilus itself. Both genes are involved in the establishment of bacteria on the root surface of rice seedlings, as detected by fluorescence microscopy. Moreover, both genes are necessary for bacterial adhesion to the mycelium of an ascomycete, which was isolated from the same rhizosphere as the bacteria. In co-culture with the fungus, Azoarcus sp. forms complex intracytoplasmic membranes, diazosomes, which are related to efficient nitrogen fixation. Adhesion to the mycelium appears to be crucial for this process, as diazosomes were absent and nitrogen fixation rates were decreased in pilAB mutants in co-culture.