According to legend, Korea was founded in 2333 B.C. At that time all the Korean tribes were united by Tangun, son of the god-spirit Hwanung. Recorded history begins in the second century B.C., when the Han dynasty from China conquered parts of Korea and established colonies. These colonies helped to transmit Chinese culture to the Koreans. Some Korean tribes managed to remain independent and from them emerged in the first century B.C. three kingdoms—Koguryo in the northwest, Paekche in the southwest, and Silla in the southeast. Gradually, the Chinese were driven out, the last colony being destroyed in 313 A.D. During the fourth century, Confucianism and Buddhism were introduced from China. In the late 600's Silla conquered the rival kingdoms and united the entire peninsula under its rule. During the Silla period, art, literature, and architecture, strongly influenced by Chinese Buddhist culture, flourished. Buddhism was made the official religion. The Silla kings, however, began losing authority over the aristocracy. By the late ninth century the country was in turmoil from constant warfare among rival clans.