A riff is a short musical phrase that is repeated throughout a piece of music but is not confined to the same pitch or rhythm as the first time it is played, in contrast to the ostinato. The riff is often improvised and can be used as a way for a musician to show off their skills.
While ostinatos are often used in classical music, riffs are commonly found in jazz, blues, and rock music.