Hello. I am a physician and also lift alot of weights. That being said, being the internet, don't take my advice as equivalent to your actual physician (legal mumbo jumbo, etc.). Anyway, the same thing happened to me last year. However, "worst headache I've ever had" is a buzzword all physician's learn in medical school to mean SAH or subarachnoid hemorrhage (see: Bret Michaels). If you're young and/or healthy, it's very unlikely that's the situation, however weight lifting does transiently elevate your blood pressure which could result in excessive stress, and eventual rupture of a weakened blood vessel in your head. Again, not to scare you, as I highly highly doubt this is your issue. But, if you at any point have neurological changes (vision changes, body weakness, numbness, loss of consciousness, etc) seek immediate help.
That out of the way... what do I think you have? Probably what I think I had - a micro tear of some of my occipital muscles. For me, it was along the back of my head, right side. For weeks, I could be absolutely fine, but the second I picked up a weight of any size, boom - pain for at least 15 minutes. I did NSAIDS (Ibuprofen or Tylenol) pre-workout, which helped some. However, I had to, albeit to my frustration, take off for a solid 2 weeks before it healed and I was able to workout pain-free. To this day, I still take NSAIDS before working out, for fear of this ever returning. Yeah, it sucked. I feel your pain. Hope this helps.