It could be any of those 3 things - spotting before your period, a UTI, or a miscarriage. Something else that comes to mind is kidney stones. Are you having any other symptoms? Symptoms of ANYTHING, I mean... body aches, rash, unexplained fatigue, pus, dark urine, etc. etc. It's tough to diagnose without a bit more info. Regardless, I would recommend making an appointment to see your doctor. If it's just spotting, that will go away when you start your period, but anything more serious your doctor will need to know and get you on the right kind of meds to help.
How was it hurting? I mean was it like a burning sensation or was it your stomach that was hurting? It could be a UTI (any fever, chills, backache?). Could be normal spotting before a period, could be another type of infection. Honestly could be anything. Best bet, see your dcotor.