Frenar (Spanish for, “to break”, particularly in the sense of, “to stop” — think of, the breaks on your car!) comes from the Latin frenare, meaning, “to restrain,” which itself is from the old Latin frenum for “birdle” — yes, the mouthpiece you put on a horse to, umm, restrain it.
From that same root, we get the English refrain. It is the same frenare root, with the re– added for emphasis. But we have the -ain spelling because it comes into English via French, with the refraigner, of course. We can see the f-r-n maps to the (re)-f-r-n very clearly as well.
The lesson here is: from restraining someone from doing something (the old sense of the word) to refraining completely from doing it (the new sense of the word) is just a minor step. At least linguistically.