Background Handgrip strength correlates with cognitive function, but how gender and dietary protein interact with it is unclear. Objective To investigate the relationship between handgrip strength and cognitive function among non-stroke elders, and potential interaction effects of gender and dietary protein. Methods Non-stroke older adults with handgrip strength and cognitive tests available were included from National Health and Nutrition Examination Survey (NHANES) database. Multivariable linear regression analyses were used to explore the association between grip strength and cognitive performance. Multivariable logistic regression analyses were to investigate the effect of weak handgrip strength on cognitive impairment. Subgroup analyses were conducted to explore differences among sub-populations. Interaction effects of gender and protein intake were investigated by interaction analyses. Results Larger handgrip strength was associated with preferable memory function in men (CERAD Word Learning sub-test: p = 0.005; CERAD Delayed Recall: p = 0.009), better verbal fluency (Animal Fluency test: p = 0.005) and executive function in women (Digit Symbol Substitution Test: p = 0.017). Weak handgrip strength was associated with cognitive impairment, especially in older, female, obese participants or elders with low protein consumption. Participants with weak grip strength, compared to normal strength, were twice as likely to perform poorly in complex cognition evaluations (odds ratio = 2.01, p = 0.028). Interaction effect of protein intake was observed (p-interaction = 0.022). Compared to conditions of low protein intake, high protein intake significantly offset the impact of weak handgrip on cognitive impairment. Conclusions The association between grip strength and cognitive performance varies by gender. Non-stroke elders with weak handgrip strength are vulnerable to cognitive impairment. Improving muscle strength and increasing protein intake may be effective to mitigate decline in executive function.