Witchcraft, technically speaking, is the conflation of diabolic activity/pacts/contact with maleficia, that is magic directed towards bad/evil ends (note that maleficia as a legal term is not necessarily limited to magic, but is the term used to describe improper/evil use of magic magic sometimes described as sorcery). We can see the origins of this idea in the 13th century, but "true witchcraft" did not emerge until the fifteenth century, but it's a concept that gradually emerged out of doctrines against heresy.
Source, Kieckhefer's intro text, Magic in the Middle Ages. Kieckhefer has published extensively on the topic, and if you're interested, I would suggest you look into his bibliography.
edit: It's important to note that witchcraft trials are a product of the early modern period, not the medieval period.