It appears that they're all descendants of the first Imam...great teachers and scholars and all of that crap.
The 12th one was "hidden" in some cave somewhere by allah, and is believed to be some kind of savior.
The slimeys like hiding in holes in the ground. Seems to be a reoccuring theme with them. Lets put them allah in the ground where they are at their bravest and happiest!
No No No, not a cave, a well.
The 12th Imam crawled down a well to hide to avoid capture.
This 12th Imam crap started sometime in the 12-14th century.
He lived in a cave in the mountains, that's probably the part of the story you are refering to. It's a special lunatic fringe sec of Shia Islamism that believes that tale. (mind you, all Islamic "scripture" and writings are handed down by lunatics)
<...ponders The Lost Tribe of Israel (numbered 12)...