In a fugue, a countersubject is "the continuation of counterpoint in the voice that began with the subject", occurring against the answer (Benward & Saker 2009, 2:50). It is not usually regarded as an essential feature of fugue, however (Walker 2001). Generally a countersubject contrasts in character to a principal subject, so if the primary subject is a stately one in long note values, the countersubject is likely to be rhythmically more active, and vice-versa.
The typical fugue opening resembles the following (Benward & Saker 2009, 2:50):
Soprano voice: Answer Alto voice: Subject CountersubjectSince a countersubject may be used both above and below the answer, countersubjects are usually invertible, all perfect fifths inverting to perfect fourths which required resolution (Benward & Saker 2009, 2:51).
In a work which is not formally contrapuntal, i.e., not a fugue or an invention, a secondary theme playing against a primary theme is usually termed a countermelody.