The literary term "pastiche" is used in two slightly different ways, and the concept can be found in other arts, not just literature, ranging from architecture to film. In the first sense, a pastiche is a form of homage which is accomplished through imitation. In the second definition, a pastiche is a medley of items which are imitative in origin. The term can be used in a derogatory or complimentary way, depending on the work under discussion.
The origins of the word lie in an Italian word meaning "medley," a reference to a type of cake or pie which is made from a broad mixture of items. The idea behind either form of pastiche is that it integrates themes, ideas, concepts, and characters which have already been seen and used before. These items are integrated in a new work because the author finds them interesting, compelling, or useful; a pastiche is not plagiarism or outright imitation, but a more complex literary concept.
In the first sense, a pastiche is often constructed as an homage or send-up of a noted author or genre. For example, Rosencrantz and Guildenstern are Dead is a playful take on Hamlet; The Story of Edgar Sawtelle is another take on Hamlet which takes on a more serious tone. Authors may produce a pastiche which imitates another author's style, borrows characters used by an author, or plays with an entire genre in literature. The numerous novels featuring the famous detective Sherlock Holmes written long after the death of Sir Arthur Conan Doyle are pastiches, for example.
In the sense of a medley, a pastiche can sometimes be successful, and sometimes be a total disaster. Some authors are very adept at weaving in many themes and concepts to create a rich and complex work, while others create a hodge-podge of items which feel incongruous and do not work together. This type of literary pastiche may be used to juxtapose characters and styles, or to illustrate the universality of themes; to borrow from Hamlet again, for example, an author could opt to create a re-telling of the story set in space in an Old Western style, integrating three very different thematic elements.
Popular culture is filled with imitation, sometimes entirely unintentional. Some themes have been used so many times that authors utilize them unconsciously, blissfully unaware of their origins. A true pastiche, however, involves a conscious decision to integrate elements of literary style from previously published works.