Although they had never met, they hit it off like old friends.
Tips
history
The phrase emerges from Tang poet Li Shangyin's 《赠田叟》: 鸥鸟忘机翻浃洽,交亲得路昧平生 — highlighting that intimacy between strangers requires shedding worldly guile.
register
Formal and literary. Often used when expressing surprise at a stranger's kindness or when introducing someone you've just met for the first time in a polite setting.