When and how was Korea divided?

During the Korean War (1950-1953).
it divided after Kim Il Sung decided that he wanted power.