The pair were released on Wednesday and had safely crossed the border into Turkey, a foreign office spokeswoman said, declining to name the woman.
“The German national and her child who was born in captivity are doing well under the circumstances,” she said, adding that they were now safely in the care of consular officers and German police.
The German embassy in Ankara was preparing their journey home.
The German government is “relieved about the positive outcome of this case given the extraordinarily difficult situation in Syria,” the spokeswoman said on Wednesday.
The foreign office gave no further details.
German media have identified the woman as a freelance journalist who travelled to Syria on the promise of getting exclusive information.
Focus magazine reported earlier this year that the 27-year-old had gone missing in October 2015, apparently kidnapped by militants from the Al-Qaeda-affiliated Al-Nusra Front who were demanding a €5 million ransom.
The weekly said she gave birth in December.
But members of the jihadist group, which is now known as Fateh al-Sham, said in a statement on Wednesday that they had nothing to do with the kidnapping and had in fact been the ones to free the woman and her baby, according to the SITE intelligence group.
The German government says it does not pay ransom demands for hostages.
The foreign office spokeswoman said German officials had made “considerable efforts to resolve the case”.
“We and the relatives and colleagues of the abducted woman are happy that this awful kidnapping has come to an end,” said Christian Mihr, director of Reporters Without Borders Germany, in a statement.
“Our thanks and appreciation go to the German authorities who prevented the abduction from becoming an execution like what happened with James Foley and other journalists. It was important that the German media protected their colleague, almost unanimously avoiding exploiting it as a sensational report.
“Our hope is that those responsible for this crime will be held accountable sooner rather than later. Only in this way can the cycle of impunity be broken.”