Rickettsia, Chlamydia and some Mycobacteria such as M.leprae are all obligate intracellular pathogens of eukaryotes. Interestingly the genome of Rickettsia has been sequenced and has shown that it is related to mitochondria. You can read about it
here. Obviously mutation and natural selection would be involved in the bacteria surviving within the eukaryote, then in the transition to parasite and finally organelle.