This page of science fiction firsts mentions the first story of a "robot without a master" that they were able to find was "Robot--Unwanted" by Daniel Keyes from 1952, although from the title and illustration this was probably just about a single free robot. Searching on google books for that title, I found p. 205 of Partners in Wonder: Women and the Birth of Science Fiction, 1926-1965 discusses some other early stories dealing with robots trying to achieve independence, including "Robots of the World! Arise!" by Mari Wolf which appeared in the July 1952 issue of Worlds of IF, available on project gutenberg here. However this may not be quite what you're looking for since it's a story about robots trying to gain independence, as opposed to a story showing AIs that have already achieved this and are living independently. Another example mentioned in Partners in Wonder which more clearly matches your criteria, whether or not it's actually the first, would be the comic book story "Judgment Day" by Al Feldstein, from Weird Fantasy #18, March/April 1953 (reprinted in this collection). Here's the description:
an Earth astronaut was sent to Cybrinia, a robot populated planet, to determine if the intelligent robots there were ready to join the Earth's Galactic Republic. He found that Cybrinia was a color-segregated society, with the dominant orange robots subjecting blue robots to ghettos and economic discrimination. The astronaut decided that Cybrinia could not joint the Republic until its robots learned, like the people of Earth, to live together without prejudice and discrimination. After the astronaut returned to his ship, he removed his helmet to reveal himself as a handsome black man with "the beads of perspiration on his dark skin twinkling like distant stars."
There is also the much earlier 1872 story Erewhon by Samuel Butler, which doesn't actually show intelligent self-replicating machines but features a character talking about the possibility as the reason their society had banned machines. The story is available on project gutenberg here, the next three chapters XXIII-XXV are the one on machines. At the end of the previous chapter XXII the author mentions that the people of Erewhon had 500 years earlier had a "revolution which had ended in the destruction of so many of the mechanical inventions which were formerly in common use", and that the revolution was in large part inspired by a book warning of the dangers of machines, which the author quotes from and summarizes in the next three chapters, you can see that the author warned that machines might both develop human-like consciousness and that they might begin to reproduce themselves:
“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?
...
“It is said by some with whom I have conversed upon this subject, that the machines can never be developed into animate or quasi-animate existences, inasmuch as they have no reproductive system, nor seem ever likely to possess one. If this be taken to mean that they cannot marry, and that we are never likely to see a fertile union between two vapour-engines with the young ones playing about the door of the shed, however greatly we might desire to do so, I will readily grant it. But the objection is not a very profound one. No one expects that all the features of the now existing organisations will be absolutely repeated in an entirely new class of life. The reproductive system of animals differs widely from that of plants, but both are reproductive systems. Has nature exhausted her phases of this power?
“Surely if a machine is able to reproduce another machine systematically, we may say that it has a reproductive system. What is a reproductive system, if it be not a system for reproduction? And how few of the machines are there which have not been produced systematically by other machines? But it is man that makes them do so. Yes; but is it not insects that make many of the plants reproductive, and would not whole families of plants die out if their fertilisation was not effected by a class of agents utterly foreign to themselves?
...
“It is possible that the system when developed may be in many cases a vicarious thing. Certain classes of machines may be alone fertile, while the rest discharge other functions in the mechanical system, just as the great majority of ants and bees have nothing to do with the continuation of their species, but get food and store it, without thought of breeding. One cannot expect the parallel to be complete or nearly so; certainly not now, and probably never; but is there not enough analogy existing at the present moment, to make us feel seriously uneasy about the future, and to render it our duty to check the evil while we can still do so? Machines can within certain limits beget machines of any class, no matter how different to themselves. Every class of machines will probably have its special mechanical breeders, and all the higher ones will owe their existence to a large number of parents and not to two only.
“We are misled by considering any complicated machine as a single thing; in truth it is a city or society, each member of which was bred truly after its kind. We see a machine as a whole, we call it by a name and individualise it; we look at our own limbs, and know that the combination forms an individual which springs from a single centre of reproductive action; we therefore assume that there can be no reproductive action which does not arise from a single centre; but this assumption is unscientific, and the bare fact that no vapour-engine was ever made entirely by another, or two others, of its own kind, is not sufficient to warrant us in saying that vapour-engines have no reproductive system. The truth is that each part of every vapour-engine is bred by its own special breeders, whose function it is to breed that part, and that only, while the combination of the parts into a whole forms another department of the mechanical reproductive system, which is at present exceedingly complex and difficult to see in its entirety.
“Complex now, but how much simpler and more intelligibly organised may it not become in another hundred thousand years? or in twenty thousand? For man at present believes that his interest lies in that direction; he spends an incalculable amount of labour and time and thought in making machines breed always better and better; he has already succeeded in effecting much that at one time appeared impossible, and there seem no limits to the results of accumulated improvements if they are allowed to descend with modification from generation to generation.
Much of the discussion in these chapters is a somewhat reworked version of an 1863 essay Butler had published titled "Darwin among the Machines" (online here), you can see a summary with quotes from both on the wikipedia page about the essay.
edit: If Butler's story is only disqualified because of the suggestion that humans were still assisting with machine "reproduction" (with Butler's analogy of insects assisting in the reproduction of flowers), another candidate is the 1878 short story by George Eliot (pen name of Mary Ann Evans), "Shadows of the Coming Race", which as with Butler featured a sort of story-within-a-story about machine domination presented as speculation by a character. This character suggests the possibility that machines may "evolve" to reproduce and repair themselves independently of human aid, asking rhetorically "how do I know that they may not be ultimately made to
carry, or may not in themselves evolve, conditions of self-supply,
self-repair, and reproduction". He also envisions the possibility of a "parliament of machines", suggesting some kind of self-government, although he also suggests that their rational behavior would be "free from the fussy accompaniment of that consciousness to which our prejudice gives a supreme governing rank, when in truth it is an idle parasite on the grand sequence of things."
This character goes on to imagine that the development of such self-replicating and rational machines would drive humankind to extinction via some version of "survival of the fittest":
What I would ask you is, to show me why, since each new invention casts a new light along the pathway of discovery, and each new combination or structure brings into play more conditions than its inventor foresaw, there should not at length be a machine of such high mechanical and chemical powers that it would find and assimilate the material to supply its own waste, and then by a further evolution of internal molecular movements reproduce itself by some process of fission or budding. This last stage having been reached, either by man's contrivance or as an unforeseen result, one sees that the process of natural selection must drive men altogether out of the field; for they will long before have begun to sink into the miserable condition of those unhappy characters in fable who, having demons or djinns at their beck, and being obliged to supply them with work, found too much of everything done in too short a time. What demons so potent as molecular movements, none the less tremendously potent for not carrying the futile cargo of a consciousness screeching irrelevantly, like a fowl tied head downmost to the saddle of a swift horseman? Under such uncomfortable circumstances our race will have diminished with the diminishing call on their energies, and by the time that the self-repairing and reproducing machines arise, all but a few of the rare inventors, calculators, and speculators will have become pale, pulpy, and cretinous from fatty or other degeneration, and behold
around them a scanty hydrocephalous offspring. As to the breed of the ingenious and intellectual, their nervous systems will at last have been overwrought in following the molecular revelations of the immensely more powerful unconscious race, and they will naturally, as the less energetic combinations of movement, subside like the flame of a candle in the sunlight Thus the feebler race, whose corporeal adjustments happened to be accompanied with a maniacal consciousness which imagined itself moving its mover, will have vanished, as all less adapted existences do before the fittest--i.e., the existence composed of the most persistent groups of movements and the most capable of incorporating new groups in harmonious relation.
Incidentally, according to the book Darwinism in the English Novel Butler took this story to be an uncredited borrowing of his own idea, though he took this as a compliment.