Both
It’s clear that magic is a natural force, and operates on natural principles. Nonetheless, witches and wizards may control and direct that force through artificial means, such as wands and incantations. We might consider a real-world parallel: the distinction between physics and engineering. Computers, for example, were invented. Unlike, say, DNA, they weren’t lying around in the natural world waiting to be discovered. But they operate on electromagnetism, solid-state physics, and information theory, which did exist in nature long before humans created the first vacuum tube. Similarly, many of the trappings of magic are wizarding inventions. Spells are manufactured entities based on natural principles of magic. Magical beings create objects from magical materials to channel magic, of which wands are the foremost example.
Magic as a natural force
Magic has concrete rules, which cannot be broken. For example, Gamp’s Laws dictate the impossibility of certain kinds of Transfiguration:
“Your mother can’t produce food out of thin air,” said Hermione. “No
one can. Food is the first of the five Principal Exceptions to Gamp’s
Law of Elemental Transfigur —”
“Oh, speak English, can’t you?” Ron said, prising a fish bone out from
between his teeth.
“It’s impossible to make good food out of nothing! You can Summon it
if you know where it is, you can transform it, you can increase the
quantity if you’ve already got some —”
Harry Potter and the Deathly Hallows
It is also impossible1 to resurrect those who have died (this may also be one of Gamp’s Laws):
“No spell can reawaken the dead,” said Dumbledore heavily. “All that
would have happened is a kind of reverse echo. A shadow of the living
Cedric would have emerged from the wand . . . am I correct, Harry?”
Harry Potter and the Goblet of Fire
Magical principles such as these can be discovered through trial and error (or possibly deduction), much like mundane laws of physics. Wizards and witches probably tried many approaches . Like laws of physics, of course, such principles are empirical; they may be mistaken, and theoretically are open to being amended if proven wrong.
The words and wand movements themselves also matter2 in magic:
“Now, don’t forget that nice wrist movement we’ve been practicing!”
squeaked Professor Flitwick, perched on top of his pile of books as
usual. “Swish and flick, remember, swish and flick. And saying the
magic words properly is very important, too – never forget Wizard
Baruffio, who said 's’ instead of 'f’ and found himself on the floor
with a buffalo on his chest.”
Harry Potter and the Sorcerer’s Stone
While probably not necessary to perform any given spell (as discussed below), they certainly seem to be inordinately helpful, so much so that some witches and wizards will refer to certain magic as “requiring” a wand:
“Come off it, Amos,” said Mr. Weasley quietly, “you don’t seriously
think it was the elf? The Dark Mark’s a wizard’s sign. It requires a
wand.”
Harry Potter and the Goblet of Fire
Harry felt the cold tip of the long white finger touch him, and
thought his head would burst with the pain. Voldemort laughed softly
in his ear, then took the finger away and continued addressing the
Death Eaters.
“I miscalculated, my friends, I admit it. My curse was deflected by
the woman’s foolish sacrifice, and it rebounded upon myself. Aaah . .
. pain beyond pain, my friends; nothing could have prepared me for it.
I was ripped from my body, I was less than spirit, less than the
meanest ghost . . . but still, I was alive. What I was, even I do not
know . . . I, who have gone further than anybody along the path that
leads to immortality. You know my goal — to conquer death. And now, I
was tested, and it appeared that one or more of my experiments had
worked . . . for I had not been killed, though the curse should have
done it. Nevertheless, I was as powerless as the weakest creature
alive, and without the means to help myself . . . for I had no body,
and every spell that might have helped me required the use of a wand.
. . .”
Harry Potter and the Goblet of Fire
Ancient magic, too, like the power of love, operates on fundamental magical principles, and thus might said to be discovered, not invented. While people can certainly develop spells that draw on this power (as Dumbledore did to protect Harry at the Dursleys’), it can also work without any human intent as long as the right conditions are met (for example, certain kinds of willing sacrifices).
Magic as a human invention
Much of what we think of as “magic” in Harry Potter is helpful-but-unnecessary tools developed human beings: i.e., invented.
For example, wand movements may matter, but at their heart wands are tools for channeling a witch or wizard’s3 natural power. As Ollivander says:
“A person can still use a wand that hasn’t chosen them, though?” asked
Harry.
“Oh yes, if you are any wizard at all you will be able to
channel your magic through almost any instrument. The best results,
however, must always come where there is the strongest affinity
between wizard and wand. These connections are complex. An initial
attraction, and then a mutual quest for experience, the wand learning
from the wizard, the wizard from the wand.”
Harry Potter and the Deathly Hallows
Because of this, there is always an element of the artificial about magic. Untrained young wizards are perfectly capable of manifesting wandless magic. Harry himself, for example, regrew his hair, floated to the top of school roofs, and many other such things.
This is not merely a peculiarity of Rowling’s earlier writing, either. More recent publications on Pottermore refer to spontaneous manifestations of wandless magic in young wizards:
Even the midwife who attended Alice Longbottom had failed to notice
that Neville managed to shift his blankets more snugly over himself
moments after birth, assuming that his father had tucked the baby in
more securely. Neville’s family persistently missed faint signs of
magic in him and not until he was eight years old did either his
disappointed great aunts and uncles, or the old stickler of a Book,
accept that he was truly a wizard, when he survived a fall that should
have killed him.
Thus, at least at the level of the instruments wizards and witches use, magic is invented, like a laptop computer or a microwave: these are tools created to allow people to extend their innate abilities.
Spells are similar. There’s not a theoretical perfect list of spells out there. Instead, witches and wizards develop them based on magical principles. As such, people usually refer to spells as being “invented”:
“No, Potter!” screamed Snape. There was a loud BANG and Harry was
soaring backward, hitting the ground hard again, and this time his
wand flew out of his hand. He could hear Hagrid yelling and Fang
howling as Snape closed in and looked down on him where he lay,
wandless and defenseless as Dumbledore had been. Snape’s pale face,
illuminated by the flaming cabin, was suffused with hatred just as it
had been before he had cursed Dumbledore.
“You dare use my own spells against me, Potter? It was I who invented
them — I, the Half-Blood Prince! And you’d turn my inventions on me,
like your filthy father, would you? I don’t think so . . . no!”
Harry Potter and the Half-Blood Prince
Various discrete spells were invented during the books. For example, Severus Snape invented Sectumsempra, Levicorpus, and Muffliato. Lord Voldemort also invented some spells to help return himself to a rudimentary form. Fred and George Weasley also developed various new and interesting kinds of magic.
Notes:
1: This rule has myriad hedges and exceptions. It’s possible to bring back echoes and temporary manifestations, to leave thinking imprints upon death, and even to communicate with the dead in a sort of limbo under very rare and unusual circumstances. In addition, if one is prepared to do something silly such as messing about with time, the dead can in a sense be brought back. This is a very foolish thing to do if one goes back more than a few hours, or in any circumstance where things could reasonably have gone much worse than they did.
2: It’s not really clear why words (and perhaps movements) matter. They’re clearly more than mere focusing aids, as various examples make apparent. It’s sometimes even possible to use a spell without having any idea of its intended usage, as long as one knows the words, as Harry did with Levicorpus and Sectumsempra. On the other hand, there’s probably not some kind of universal magical language, as in the Inheritance Cycle, since many of the spells seem to have specific linguistic origin, and magic certainly predates the origins of some or all spells mentioned. Words definitely have magical significance, but it’s not clear how they acquire it.
3: Witches and wizards are not the only entities that can use wands. Goblins and elves, at least, and probably many other creatures, are perfectly capable of using wands, but are disenfranchised by wand laws biased against non-humans. To paraphrase Sheev Palpatine: “They don’t trust you. They know your power will be too strong to control.”