The WRKY gene family is widely distributed in plants and is known to play essential roles in stress response. However, the underlying structure and evolution of WRKY in cotton remains elusive. Herein, 112, 119, 217, and 222 WRKY genes were identified in G. arboreum, G. raimondii, G. hirsutum, and G. barbadense, respectively. The 670 WRKYs were divided into seven subgroups and unevenly mapped to chromosomes. Analysis of motifs, domains, cis-acting elements, and gene structure collectively revealed the evolutionary conservation and diversity of WRKYs in cotton. Synteny and collinearity confirmed the expansion, duplication, and deletion of WRKYs during the evolution of cotton. Further, GhWRKY31 was induced by osmotic and salt stress. Ectopic expression of GhWRKY31 improved osmotic and salt tolerance in Arabidopsis, while silencing GhWRKY31 in cotton increased sensitivity to drought and salinity. This was observed through higher germination rates and root length in GhWRKY31 transgenic Arabidopsis, as well as lower levels of ABA, proline, POD, and SOD in GhWRKY31-VIGS cotton plants under stress. Additionally, silencing of GhWRKY31 reduced the expression levels of drought- and salt-related genes, including GhRD29, GhNAC4, GhABF1, GhABF2, GhDREB2, GhP5CS, and GhSOS1. Yeast one-hybrid and molecular docking experiments confirmed that the GhWRKY31 domain binds to the W box of GhABF1, GhDREB2, and GhRD29, and is connected by hydrogen bonds. Collectively, the results provide a systematic and comprehensive understanding of the evolution of cotton WRKYs, and suggest an appropriate regulatory network for breeding cotton varieties with improved drought and salinity tolerance.