Yevamos4: 2
הַכּוֹנֵס אֶת יְבִמְתּוֹ וְנִמְצֵאת מְעֻבֶּרֶת וְיָלָדָה, בִּזְמַן שֶׁהַוָּלָד שֶׁל קְיָמָא — יוֹצִיא וְחַיָּבִין בְּקָרְבָּן. וְאִם אֵין הַוָּלָד שֶׁל קְיָמָא — יְקַיֵּם. סָפֵק בֶּן תִּשְׁעָה לָרִאשׁוֹן, סָפֵק בֶּן שִׁבְעָה לָאַחֲרוֹן — יוֹצִיא וְהַוָּלָד כָּשֵׁר, וְחַיָּבִין בְּאָשָׁם תָּלוּי.
[If] someone married his yevamah, and [then] she was found to be pregnant and she gave birth —- if the child is capable of liv- ing, he must discharge [her], and they are obligated to bring an offering; however, if the child is not capable of living, he may retain [her]. [If] it is not clear whether it is the nine-month child of the former [husband] or the seven-month child of the latter, he must divorce [her], the child is legitimate, and they are obligated to bring a pending guilt-offering.