Ana Ivanovic beat Russia's Svetlana Kuznetsova in three sets, 3-6, 6-4, 7-6 (7-4), to win the WTA's German Open in Berlin.