I think the presumptive etymon is Scots or dialectal “whank”, which is surely the same as the Leicester word noted by ElizaD above. Some sources say the usual spelling of the modern slang word was “whank” once. I think it is said to have been primarily UK armed forces slang ca. 1950 (Partridge et al.).
I suppose the German “wanken” is unrelated but I defer to anyone who is knowledgeable in German. Kluge connects this word etymologically (distantly) with Latin “vacillare”.
I don’t think “wank” is usual in the US although of course some know it. Possibly it has become known very recently via “Austin Powers” or some such thing, but I’ve never heard it in natural US speech myself. It was known to me only slightly (as one of dozens of esoteric expressions for the same act) in 2000 when I first heard of an alteration proposed for a revised edition of Jack Vance’s science fiction novel “Servants of the Wankh” ... to avoid offense or derision in the UK, apparently.
Here is a recent UK reference to this amusing case (there is also a “Wankh” Wikipedia page):
No surprise that nobody noticed anything wrong with the word “Wankh” (which referred to a race of aliens) in the 1969 US, since the word “wank” simply wasn’t generally known in the US. I’ll bet the great majority of US-ans will fail to recognize it today.
Surprising to me, though: the book was published with the same title in two separate UK editions in 1975. Didn’t the UK editors have anything to say? Surely at least the title could have been modified (e.g., “The Servants” would suffice) to avoid any wrong ideas? (Other Vance novels have appeared under varying names.) Or maybe “wank” wasn’t universally familiar to UK-ans then?