Phosphoinositides are essential signaling lipids that play a critical role in regulating ion channels, and their dysregulation often results in fatal diseases including cardiac arrhythmia and paralysis. Despite decades of intensive research, the underlying molecular mechanism of lipid agonism and specificity remains largely unknown. Here, we present a systematic study of the binding mechanism and specificity of a native agonist, phosphatidylinositol 4,5-bisphosphate (PI(4,5)P2) and two of its variants, PI(3,4)P2 and PI(3,4,5)P3, on inwardly rectifying potassium channel Kir2.2, using molecular dynamics simulations and free energy perturbations (FEPs). Our results demonstrate that the major driving force for the PI(4,5)P2 specificity on Kir2.2 comes from the highly organized salt-bridge network formed between the charged inositol head and phosphodiester linker of PI(4,5)P2. The unsaturated arachidonic chain is also shown to contribute to the stable binding through hydrophobic interactions with nearby Kir2.2 hydrophobic residues. Consistent with previous experimental findings, our FEP results confirmed that non-native ligands, PI(3,4)P2 and PI(3,4,5)P3, show significant loss in binding affinity as a result of the substantial shift from the native binding mode and unfavorable local solvation environment. However, surprisingly, the underlying molecular pictures for the unfavorable binding of both ligands are quite distinctive: for PI(3,4)P2, it is due to a direct destabilization in the bound state, whereas for PI(3,4,5)P3, it is due to a relative stabilization in its free state. Our findings not only provide a theoretical basis for the ligand specificity, but also generate new insights into the allosteric modulation of ligand-gated ion channels.