The first thing that comes to my mind is FHS, Feline Hyperesthesia Syndrome.
The twitching and attacking himself are classic indications of this.
My recommendation, if this continues, is that you make him an appointment at the vet, video tape some episodes, and read up on FHS.
Often, it can be controlled with a diet change, eliminating things like anything artificial (preservatives, colors, flavors) sodium nitrites and sodium nitrates, grains etc. Sometimes medication is required. Vets seem to want to start with things like prozac (fluoxetine) or amitriptyline, the worse case scenario is a cat who needs phenobarbital.
Having said all that, other thoughts are: perhaps he's picked up a flea. If he's never had fleas, even one flea could be very upsetting. Or, something happened while you were away that frightened him, a loud noise from a neighboring apartment for instance.
Or pain. You said he peed last night, good, But has he peed since? Urinary tract blockage of course is always the first worry about males, I don't know what you feed him. Gas built up in the stomach, from a hairball lodged somewhere could also cause enough pain to cause strange behavior.
I had a cat once who had gas pain so bad he was screaming in pain. It was terrifying.
No matter what, if it continues, a trip to the vet is in order.