The allusion is to bats - the erratically flying animals, and 'belfries' are the bell towers often found at the top of churches. 'Bats in the belfry' refers to someone who acts as though he has bats careering around his topmost part, i.e. his head.
It might sound English in origin. It certainly has the right imagery to crop up in any number of Gothic novels based in English parsonages or turreted castles. In fact, it comes from the USA. Nor is it especially old. All the early citations are from American authors and date from the early 20th century. For example, firstly from the American author George W. Peck, in his Peck's Uncle Ike and the Red-Headed Boy, circa 1901:
"They all thought a crazy man with bats in his belfry had got loose."
Ambrose Bierce, also American, used the term in a piece for Cosmopolitan Magazine, in July 1907:
"He was especially charmed with the phrase 'bats in the belfry', and would indubitably substitute it for 'possessed of a devil', the Scriptural diagnosis of insanity."
Belfries are no longer common of course. Just as well that we don't appear to need them to express craziness - bats alone is now enough. The use of 'bats' and 'batty' to denote odd behaviour originated around the same time as 'bats in the belfry' and is clearly related. Again, the early authors to use the words are American:
1903 A. L. Kleberg - Slang Fables from Afar: "She ... acted so queer ... that he decided she was Batty."
1919 Fannie Hurst - Humoresque: "'Are you bats?' she said."