Ostapenko denied Halep of a chance to become world number if she won.
Halep won the first set and was 3-0 ahead in the second before 20-year-old Ostapenko fought back to take the second set at Roland Garros.
The win secured Ostapenko her first Grand Slam title. She racked 47th in the world
Halep was playing in her second French Open final, after losing in three sets to Maria Sharapova in 2014.