"Mother and baby are both in a stable condition," said the Ministry of Defence, following the birth on Tuesday in Camp Bastion, Helmand province.
The woman, a Royal Artillery gunner who has not been named by the MoD, only learned she was about to give birth after complaining of stomach pains.
The child was conceived before she arrived in Afghanistan in March.
In a statement, the MoD said: "It is not military policy to allow servicewomen to deploy on operations if they are pregnant. In this instance the MoD was unaware of her pregnancy."
A specialist paediatric team from Oxford's John Radcliffe Hospital is to fly to Afghanistan in the next few days, the statement added, "in order to provide appropriate care for mother and baby on the flight home".
The baby was born five weeks prematurely.
BBC defence correspondent Caroline Wyatt said it is the first time that a British soldier has given birth on the front line.
"Though up to 200 servicewomen have been sent home since 2003 from Iraq and Afghanistan when it was discovered they were pregnant," she said.
"This unusual case may well fuel further debate over whether more medical checks are needed before the armed forces deploy women to the front lines."