Toward the end of the Tang Dynasty, the government faced

an invasion of armies from the north.
a series of rebellions in the outer areas.
a widespread plague that killed thousands.
a battle among members of the royal family.