1580s, "pertaining to bats," from bat (n.2) + -y (2). Slang sense "nuts, crazy" is attested from 1903, from the expression (to have) bats in (one's) belfry, also meaning "not be right in the head" (1899).