Many pathogenic bacteria use a type III secretion nanomachine (an injectisome) to deliver virulence proteins into the cytosol of their eukaryotic host cells. Most injectisomes possess a stiff needlelike structure of a genetically defined length. We found that a minimal needle length was required for efficient functioning of the Yersinia enterocolitica injectisome. This minimal needle length correlated with the length of the major adhesin at the bacterial surface. The needle may be required for triggering type III secretion, and its length may have evolved to match specific structures at the bacterial and host cell surfaces.