Hostile machine intelligences are discussed in Erewhon, a 1872 satirical novel by Samuel Butler. This is kind of an unusual example, since the artificial intelligence is fictional in-universe. Most of the novel is a satire in the vein of Gulliver's Travels. However, three chapters near the end are framed as the narrator's (incomplete) translation of an in-universe polemical document, which calls for the destruction of all advanced machines, because the machines are evolving so quickly that they may soon be more intelligent than humans—something that the author considers a very threatening prospect.
The writer, after enlarging on the above for several pages, proceeded to inquire whether traces of the approach of such a new phase of life could be perceived at present; whether we could see any tenements preparing which might in a remote futurity be adapted for it; whether, in fact, the primordial cell of such a kind of life could be now detected upon earth. In the course of his work he answered this question in the affirmative and pointed to the higher machines.
“There is no security”—to quote his own words—“against the ultimate development of mechanical consciousness, in the fact of machines possessing little consciousness now. A mollusc has not much consciousness. Reflect upon the extraordinary advance which machines have made during the last few hundred years, and note how slowly the animal and vegetable kingdoms are advancing. The more highly organised machines are creatures not so much of yesterday, as of the last five minutes, so to speak, in comparison with past time. Assume for the sake of argument that conscious beings have existed for some twenty million years: see what strides machines have made in the last thousand! May not the world last twenty million years longer? If so, what will they not in the end become? Is it not safer to nip the mischief in the bud and to forbid them further progress?
The full discussion is actually quite sophisticated, and addresses a number of practical and philosophical objections to the idea of machines being alive or intelligent. Butler had begin considering these issues a number of years earlier, and the discussion in Erewhon was an elaboration on some earlier ideas he had laid out in the 1863 essay "Darwin Among the Machines." Butler's body of work on this topic is considered by many to represent the first serious attempt to consider the possibility of artificial intelligence, including the ways in which it would be similar to naturally-evolved intelligence and also the key ways in which it would be difference.
The actual hostility of super-intelligent machines is something that Butler seems to take mostly for granted. He compares how humans treat the less clever and conscious organisms of our planet, and, by analogy, concludes that if machines surpass us, they will most likely press us into subservience as human livestock. He does not think that this will necessarily be the result of a violent robot uprising; rather, Butler thinks it more likely that humans will gradually become more and more dependent on the technology that was originally humanity's own creation, until people are virtual slaves, and the machines have supplanted them as the primary decision makers.