the answer is counterpoint.
counterpoint definition: "the art or technique of playing a melody or melodies in conjunction with another, according to fixed rules."
counterpoint is present in a lot of baroque music- such as bach (notably his wtc prelude and fugues) and scarlatti, but can also be found in music by mozart, beethoven. it can even be found in music as modern as john williams!