It appears to me that the midwife is only believed when there is no challenge against her, but if there is one who contradicts her, and even if a woman contradicts her and says that the second one is the firstborn, the midwife is not believed. For the midwife's credibility applies also to a kohen, a levi, a yisrael, and a mamzer, and we hold that when there is a challenge, she is not believed, as is written in Even HaEzer siman 4. And even though in every place where the Torah believed one witness, he is like two and one witness is not believed to disqualify him, in truth the midwife's credibility is only because most of the time it is impossible otherwise [Ran there]; for at the time of birth, most of the time there is only the midwife and the mother, and the mother is mostly unable to know who emerged first, as she is preoccupied with her pangs and birth-throes. And it is not similar to every credibility of one witness in a matter that is destined to be revealed, such as an agunah to testify that her husband died. And even though in any matter that has neither a presumption of permission nor a presumption of prohibition one witness is believed, as is written in Yoreh Deah siman 127, that is regarding prohibitions, but in matters of money and lineage we have not found that one witness should be believed [and the question of the Chelkat Mechokek on the Ran is answered]. Rather, her credibility is because it is impossible without her, and therefore when someone comes and contradicts her, she is not believed. And all the more so when the father or the mother contradict her, she is not believed [Taz there]. And specifically when they contradict her on their own, but if they contradict her to say that she herself said about the other child that he is the firstborn and she contradicts them, she is believed, according to the law of "a certain sage purified the blood for me" and he contradicts her [it appears to me]. And from the Rambam in chapter 15 of Issurei Biah, it is implied that the reason for the midwife's credibility is because it was not established. And in truth, the midwife's credibility is explicit in the Torah regarding Tamar, where the midwife established Perez as the firstborn, and so it is implied in the Yerushalmi and Kiddushin [chapter 4]. And furthermore, we learned from Tamar that even if one extended his hand and the midwife made a sign to know that he is the firstborn, she is believed afterward to say that this one withdrew his hand and the other emerged first, as it was with Perez and Zerach. And nevertheless, it is not difficult that one witness is believed to contradict her since the Torah believed her, for it can be said: specifically in a place that requires two witnesses, such as a married woman, a sotah, and an eglah arufah, and the Torah believed one, he is indeed like two and one is not believed to contradict him; but in this case where the midwife is believed, two are not required by the core law since there is no presumption here at all, and by law one witness is believed, and therefore one is also believed to contradict him [and although from Tosafot at the beginning of the third chapter of Keritot it is implied not like our words, nevertheless in the Nimukei Yosef, parashat HaIshah Rabbah, he wrote according to this reasoning in the name of the Ritva].
יראה לי דאין החיה נאמנת אלא כשאין ערעור עליה אבל אם יש אחד שמכחישה ואפילו אשה מכחישה ואומרת שהשני הוא הבכור אין החיה נאמנת דהא נאמנות החיה הוא גם בכהן ולוי וישראל וממזר וקיי"ל דכשיש ערעור אינה נאמנת כמ"ש באהע"ז סי' ד' ואף על גב דבכל מקום שהאמינה תורה עד אחד הרי הוא כשנים ואין עד אחד נאמן לפוסלו דבאמת נאמנות החיה אינו אלא מפני שע"פ רוב לא סגי בלא"ה [ר"ן שם] דבשעת הלידה אין ע"פ רוב רק החיה והאם והאם אין ביכלתה ע"פ רוב לידע מי יצא ראשון דטרודה בציריה וחבליה ולא דמי לכל נאמנות עד אחד במילתא דעבידא לגלויי כמו בעגונה להעיד שמת בעלה ואף על גב דכל דבר שאין לו חזקת היתר וחזקת איסור נאמן עד אחד כמ"ש ביו"ד סי' קכ"ז זהו באיסורים אבל בממון וביחוס לא מצינו שיהא עד אחד נאמן [ומתורץ קושית הב"ש על הר"ן] אלא נאמנותה משום דא"א בלעדה ולכן כשבא מי שהוא ומכחישה אינה נאמנת וכ"ש דכשהאב או האם מכחישים אותה דאינה נאמנת [ט"ז שם] ודוקא שמכחישים אותה מעצמם אבל אם מכחישים אותה לאמר שהיא בעצמה אמרה על הוולד האחר שהוא בכור והיא מכחישתם היא נאמנת כדין פלוני חכם טהר לי את הדם והוא מכחישה [נ"ל] ומהרמב"ם פט"ו מאיסורי ביאה משמע דטעם נאמנות החיה מפני שלא הוחזק ובאמת נאמנות החיה מפורש בתורה גבי תמר שהמילדת החזיקה את פרץ לבכור וכן משמע בירושלמי וקדושין [פ"ד] ועוד למדנו מתמר דאפילו הושיט האחד את ידו ועשתה המילדת סימן לידע שהוא בכור נאמנת אח"כ לומר שזה השיב ידו והאחר יצא ראשון כמו שהיה אצל פרץ וזרח ומ"מ לא קשה מה שעד אחד נאמן להכחישה כיון דהתורה האמינתה די"ל דוקא במקום שצריך שני עדים כמו באשת איש ובסוטה ועגלה ערופה והתורה האמינה לאחד הוה שפיר כשנים ואין אחד נאמן להכחישו אבל בזה שהחיה נאמנת א"צ שנים מעיקר הדין כיון שאין כאן חזקה כלל ומדינא עד אחד נאמן ולכן נאמן גם אחד להכחישו [ואף שמתוס' רפ"ג דכריתות משמע דלא כדברינו מ"מ בנמק"י פ' האשה רבה כתב כסברא זו בשם הריטב"א]: