The 26th seed Kostyuk secured her maiden WTA 1000 title defeating the No 9 seed Andreeva.
Andreeva beat Hailey Baptiste in the semi-finals, Leylah Fernandez in the quarter-finals, Anna Bondar in the fourth round, Dalma Galfi in the third round and Panna Udvardy in her opening match.
Kostyuk defeated Anastasia Potapova in the semi-finals, Linda Noskova in the quarter-finals, Caty McNally in the last 16, Jessica Pegula in the third round and Yulia Putintseva in her first match.
This was the second-ever match between the pair, with Kostyuk having downed Andreeva 7-6(7), 6-3 in the quarter-finals at the Brisbane International in January.
Kostyuk has secured 1,000 ranking points for winning the Madrid Open, which increases her points total to 2,507.
This has lifted the 23-year-old Ukrainian eight places to a new career-high ranking of world No 15.
Andreeva's runner-up result has earned her 650 points, which puts her on 4,181 points and moves her up one place to world No 7.