An ace in the hole is like a last trick up one's sleeve, something one hides until the crucial moment. The "in the hole" part of this phrase insinuates two meanings: One, that the owner of said "ace" is "in the hole," as in being the underdog or losing in a game or situation; and two, that the ace itself is hidden, though the first meaning is the intended one. Obviously the phrase refers to playing cards, as an ace is often a highly-valued card, but this phrase generalizes to many other situations.