ABSTRACT: The NLR apoptosis inhibitory proteins (NAIPs) function as specific cytosolic receptors for bacterial ligands to form the NAIP-NLRC4 inflammasome for anti-bacterial defenses. In mice, NAIP5/6 and NAIP2 recognize bacteria flagellin and the rod protein of the type III secretion system (T3SS), respectively. However, molecular mechanism for specific ligand pattern-recognition by the NAIPs is largely unknown. Here, through extensive domain swapping and truncation analyses, three structural domains, the pre-BIR, BIR1, and HD1, in NAIP2 and NAIP5 are identified, that are important for specific recognition of their respective ligand(s). The three domains are sufficient to confer the ligand specificity for NAIP2. Asp-18, Arg-108, and Arg-667, respectively, in the pre-BIR, BIR1 and HD1 of NAIP2 are further identified, each of which is essential for efficient binding to the rod protein. To our surprise, we find that the C-terminal leucine-rich repeat domain is dispensable for NAIP2 recognition of the T3SS rod protein, but is required for NAIP5 binding to flagellin. At the ligand side, we discover that the C-terminal 35 residues in flagellin are crucial for binding to NAIP5. Among the 35 residues, three critical residues are identified, which determine flagellin recognition by NAIP5 and subsequent inflammasome activation. The differences in the three amino-acid residues among flagellins from various pathogenic and commensal bacterial species correlate well with whether they are susceptible to NAIP5-mediated immune detection. Taken together, our studies identify critical sequence and amino-acid determinants in both NAIP receptors and the bacterial ligand flagellin that are important for the specificity of the pattern-recognition.