The word pronounced wansui (Traditional Chinese: 萬歲; Simplified Chinese: 万岁) in Chinese and banzai in Japanese literally means (live for) ten thousand years (sui means age). It was used to bless emperors in East Asia. It can be repeated multiple times (in China, it was customary to pay respects to the Emperor by saying "Wansui, wansui, wanwansui"; the last one indicates ten thousand ten thousands, or 100 million years). It is usually translated into English as "Long live!" although it has historical connotations that are not present in the English phrase. "Ten thousand" in Chinese numerals has a connotation of infinity, innumerability, similar to Greek myriad.
Although it was once used casually like "Cheers to your health", it came to be used by the emperor during the Tang Dynasty. It became a prayer from the emperor's long life and reign. In later Imperial history, using it to address someone other than the emperor was considered an act of rebellion and consequently highly dangerous. In modern times the term is posted on the gates of the Forbidden City in which there are large signs which read "Long live the People's Republic of China" and "Long live the unity of the world's people". During the Cultural Revolution, the saying was commonly used to toast Mao Zedong - "Mao Zhuxi Wansui!" With these exceptions the term has largely fallen into disuse in Chinese societies.
It was introduced to Japan, but at that time, was pronounced "banzei". Its early instances can be found in the 8th century. It expressed respect for the emperor in Japan too.
Banzei was revived as "banzai" after the Meiji Restoration. Banzai as a formal ritual was established in the promulgation of the Meiji Constitution in 1889 when university students shouted banzai in front of the emperor's carriage.
At the same time, banzai also came to be used unrelated to the emperor. The supporters of freedom and people's rights movements began to shout "Jiyū banzai" (自由万歳 Long Live Freedom) in 1883. Today banzai becomes a word of congratulation.
Wansui is pronounced manse in Korean, whose usage was influenced by Japanese one. Historically, the Koreans were not allowed to use manse for their king because it was exclusively used for the Chinese emperor. Instead cheonse (千歲 one thousand years) was used for the king of Korea.
See also: Emperor of China, Emperor of Japan