Two of the most important elements in any work of fiction, I feel, are foreshadowing and fair play ... which in some cases are even interchangeable. When writing, I apply them to many of the elements of story.
Foreshadowing, of course, is the use of elements or hints in the story to prepare the reader for what is to come - a glimpse ahead. Fair play, for me, is a shorthand for the rules of fair play used in mystery novels. These are the standards that allow a mystery reader to play along with the detective.
But foreshadowing and fair play are applicable in more situations than setting up a big event or building up a mystery. I find fair play particularly important when building towards a twist or revelation - a sudden change in the story that makes perfect sense in hindsight.
To be satisfying, any twist (especially a twist ending) needs to have solid grounding in the facts of the story - and the reader has to be aware of these facts. So creating a good twist is something like a mystery: you put in clues for the reader leading to an "aha!" moment. Perhaps the main difference is that in the mystery, the author is rooting for the reader, whereas in the twist, the author is trying to trick the reader ... but both play by game rules.
To play fair with a twist, however, you can't fool all of the people all of the time, so I've never been fond of stories that depend solely on the twist for interest.
Foreshadowing can be used not only for major plot elements, but for the evolution of character interaction. Romance, in particular, has its own elaborate language of foreshadowing, hints and touches and baby steps that range from so subtle even the reader may miss them to painful, blunt thudding-over-the-head.
In fact, I like to apply both fair play and foreshadowing to the overall development of plot - any plot. If the character has a knack for gardening that will turn out to be the common element with the sea monster he meets in the final sequence (... work with me, here), I had better hear him praising the azaleas in the beginning of the story. If the primary race in the story has telepathy, it shouldn't come up the first time a third of the way through - when one of the characters mindspeaks another so they can coordinate their escape plan.
Does this mean everything is known ahead of time? Hardly. Just because the reader might pick out that this piece or that is significant doesn't mean they know how it will come into play ...
It's a delicate balance between predictability and deus ex machina - but if I must err in one direction, it would be the former. Enjoyment of a story should never be predicated on surprise. It should be the organic product of everything that comes before, and the reader finding out they were right should be just as satisfying as the reader finding out they were wrong.