哀れみ is a more emotional, often personal feeling of pity. 憐憫 is more formal and can be used in abstract or moral contexts.
Etymology
From Middle Chinese 憐憫 (len min). The kanji 憐 means 'pity' or 'sympathy', and 憫 means 'compassion' or 'grief'. The exact historical derivation is uncertain, but the compound has been used in literary Japanese for centuries.