She first met the Doctor at a family picnic when a Starman attacked those nearby. Ali pocketed a silver orb which was left behind after the Starman left the area.
Ali was a college student. Over the course of her education she learned in science that TARDISes were theoretically possible and in ancient history she was told that Time Lords were extinct. Although she considered technology "ridiculously retro", she was proficient in using it.
A few days after their first encounter, Ali met the Doctor again and accompanied him as he hunted the Starman to Babylon in Earth's ancient history.
The Doctor and Ali defeated the Starman, and the Doctor took her back home to Karkinos. Although Ali had saved his life and in fact had helped save the day, the fact she allowed herself to go into a battle rage and mercilessly kill a number of Babylonian soldiers made him uneasy, and he indicated he would not take her on as a companion.
On Karkinos, Ali persuaded the Doctor to go back to Rose Tyler, a human that he had met shortly before he first met her.