Oh boy! FINALLY a question right up my alley. You're probably thinking more about medieval western Europe, but I can offer a perspective from the Byzantine Empire.
Some Background:
The practice of alchemy is ancient, extending back into ancient Egypt and to the artisanal/industrial "recipes" of Mesopotamia. What we conceive of as "Western" alchemy has its roots in the intersection of artisanal practice, religion, and philosophy in late antique Roman Egypt. The earliest surviving alchemical documents of this tradition are the so-called Leiden and Stockholm papyri, two papyri that were supposedly discovered near Thebes. The content of the two papyri is very similar, and is mostly concerned with the coloration of metals, the creation of purple dyes, and the fabrication of artificial pearls and gemstones. The Stockholm papyrus in particular makes reference to a philosopher named "Democritus," a reference to the fifth-century BCE atomist Democritus of Abdera. By the time the papyri were compiled in the fourth century CE, there was a fully developed tradition of alchemical practices attributed to Democritus, who was purportedly a student (along with Plato and Alexander the Great) of a Persian sorcerer, Ostanes. Around the first century CE, one or several authors writing pseudonymously under the name Democritus composed four books on alchemy, one each on the making of gold, the making of silver, the making of purple dyes, and the making of gemstones. The content of these four books survives only as a Byzantine-era epitome (a summary, basically), known best by the title Physika kai Mystika ("Natural and Secret Questions"). The Physika kai Mystika brings together a compilation of recipes for coloring metals and gives them a theoretical framework, arguing basically that the practice of alchemy is a branch of the natural sciences, and that with the proper understanding of the sympathies and antipathies of a given material's properties, one can manipulate those properties into the desired form (usually gold).
At around the same time as the composition of the Leiden and Stockholm papyri, at the height of the circulation of Pseudo-Democritus' Four Books, the Alexandrian philosopher Zosimos of Panopolis began composing a number of books about alchemy that he dedicated to a certain Theosebeia, either an aristocratic patron or perhaps his own sister. The ninth-century Suda lexicon tells us that Zosimos wrote 28 books on alchemy, although again, only a few Byzantine summaries exist. This Greco-Egyptian tradition of alchemy persisted into the middle ages, circulating to the Latin-speaking world and resulting in the composition of surviving texts like the Mappae Clavicula (a collection of recipes very similar to the Leiden and Stockholm papyri). The point of this long back story is basically to clear up some misconceptions about what medieval people understood alchemy to be. Alchemy was foremost a branch of natural philosophy, with a practical, "laboratory" aspect drawn from practices of artisanal production. While alchemy was occasionally closely associated with magic (the Leiden and Stockholm papyri were authored by the same scribe as a number of Greek magical papyri), alchemy was foremost seen as a kind of philosophy.