HOUSTON - Yonder Alonso, the A’s top All-Star candidate, left the team’s game against the Astros on Wednesday night after slamming a foul ball off his right knee.

Alonso fell to the ground in agony, grabbing his knee, and remained down at the plate for several minutes before limping off the field with manager Bob Melvin and a trainer.

Rajai Davis replaced him with a 2-2 count and struck out, which will be credited to Alonso.

Alonso is batting .283 with 17 homers and 38 RBIs.

Susan Slusser is a San Francisco Chronicle staff writer. Email: sslusser@sfchronicle.com Twitter: @susanslusser