The phrase
尊王攘夷 originates with Duke Huan of Qi and his minister Guan Zhong
管仲 (~7th century BCE), rallying Zhou-dynasty vassals against nomadic incursions. Bakumatsu Japan revived it (
尊皇攘夷, sonno joi) as the slogan against Western powers in the 1850s-60s.