The answer is that he imagined it - obviously! He could not perceive it, therefore he must have imagined it - or, if you like, inferred it.
Darwin did know that selection could adapt organisms, because artificial selection was well established among animal breeders. Artificial selection could adapt a species - such as horses, cattle, sheep, dogs, fancy pigeons - to the requirements of the animal breeder. Darwin saw that the natural world could do something very similar - adapt a species to the requirements of its environment.
Darwin then imagined that a continuation of this process over many generations could join-up the taxonomy of living things established by Linnaeus and others - or rather, could join up the inferred ancestors (common ancestors) of currently alive (or known from fossils) living thing which had since then been adapted to their later environments.
In sum, Darwin imagined that the qualitative difference's between living things on earth could be reconceptualised as quantitative differences - especially in what were also inferred to be homologous features (such as the mammalian arm and the birds wing, or the mammalian hand and the bat's wing).
(Note I don't doubt that these features are homologous but note that there is no objective method for detecting homologous features - the nature of structures assumed to be homologous is itself a thing imaginatively grasped.)
Given that Darwin's scheme was imaginative, and involved a great deal of inference and interpolation, why did it become regarded as the only valid explanation of the evolution of species and the only valid description of the history of life on earth? (And any significant gaps, or unsatisfactory parts, of the complete validity of the theory of evolution by natural selection, are regarded as merely being 'not-yet-discovered' - awaiting future developments.)
The answer is not that there emerged overwhelming evidence to support evolution by natural selection as the only explanation of the origin of species - because there is not more evidence to support this idea now than the was when Darwin first proposed it.
Thus, the decision to adopt evolution by natural selection as the sole officially accepted explanation for all life origins was arbitrary from a biological perspective.
(Implying that the reason it was adopted was not biological - but presumably psychological, social, political - or something of that sort.)
But having adopted it, biology then operated within the theory of natural selection - the theory controlled the conduct of biology, what counted as evidence, and permissible ways to interpret evidence. The theory became un-disprovable - as are all metaphysical assumptions.
This did not seem to have harmed the development of biology as a domain for professional careers; however, when evolution by natural selection was considered to be The Truth about life, and abut Human life, then its socio-cultural effect has been extreme and pervasive.
My point here is not to discredit the theory of natural selection as having been imagined - but rather to point out that what Darwin imagined may legitimately be re-imagined, and differently.