Before quoting some sources
Before quoting sources one must be aware that the culture of documenting dates of birth or death -sometimes- seems to me as a strange thing in the Arabic culture, even nowadays so most dates of birth of death at the time were related to a big historical event and must be taken as more or less good approximation (May draft question here https://islam.meta.stackexchange.com/a/3029/13438 wanted to express this observation). So when reading the biography of the Prophet we say he was born at the year of the Elephant because this event was the most important happening for a long time period especially in the hijaz and maybe in the whole Arab Peninsula. So it is quite hard and difficult to give an exact date of birth of people who were born before or afterwards as maybe the next important Event was Muhammad's prophet-hood or the hijra which both happend many decades later.
Of course some earlier scholars expressed their doubts or commented on the "seemingly known marriage age of Khadija of 40 years", due to the fact that she has given birth to almost all children of Muhammad () and therefore she would have given birth in an age higher than 50 years or even close to 60 if we trust those narrations saying she died at the age of 65!
This can be explained by the example of Sarah the wife of the prophet Ibrahim () whom gave birth to a child in her 80's or 90's some even pretend at the age of 99 because of Allah's will. The maybe strongest and often used evidence from hadith science to defend the age of 40 is a hadith narrated by both al-Bukhari and Muslim on the authority of 'Aisha whom called or described Khadija as an old woman (some scholars said even if this is or might be exaggerated out of jealousy, but could nevertheless be an evidence that she remembered her in a high age ~55-60).
We also nowadays still witness that women give birth after an age of 50, even if those cases are not that common.
In some of the comments I often found al-Hakim as the most quoted scholar criticizing those narrations, but on the other hand giving some inconsistent opinions: sometimes saying she died at the age of 52 based on a marriage age of 28, or saying she at least was younger then 60 when she died or quoting an age of marriage of 25 or 35 years (I couldn't find all of these quotes in their possible sources). An other hurdle i found is that while ibn Sa'ad has narrated once from al-Kulaibi and once from al-Waqdidi and al-Hakim once on the authority of ibn Ishaaq and once on the authority of Mosa'ab ibn Abdullah az-Zubayri and Hisham ibn 'Urwah commented both of them I often find quotes pretending that he commented on al-Waqidi's hadith instead which seems hard to verify.
Maybe "the dilemma of the marriage age" on the sunni side is also due to the fact that they attribute 3 other daughters than Fatima to Khadija, while shi'a solve the issue by pretending they were daughters of one of her sisters whom grow up in Khadija's household.
Note that on shi'a sites i found blind references to sunni sources where even the quotations where not fully (for example the quotation from ibn Sa'ads tabaqat was quoted without ibn Sa'ads commentary on it) quoted as in the source to emphasize on the fact that sunni's indirectly admit that Khadija was the first virgin Muhammad () married. Also shi'a seem to rely a lot on the strange narrations or qualifications of al-Hakim in his Mustadrak and elsewhere(?).
Quotes from ibn Sa'ads tabqat
Let's start by ibn Sa'ads ابن سعد tabaqat الطبقات الكبرى:
The first narration he quotes (on the authority of al-Waqidi) about the marriage says Khadija () was 40 years old. Here the relevant part (the last few sentences which quote a statement of Khadija's paternal uncle -whom was her guardian for marriage as her father was already dead-) - My own translation, this applies to all the Arabic<>translations if I didn't quote an English source-:
وَتَزَوَّجَهَا رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ وَهُوَ ابْنُ خَمْسٍ وَعِشْرِينَ سَنَةً وَخَدِيجَةُ يَوْمَئِذٍ بِنْتُ أَرْبَعِينَ سَنَةً ، وُلِدَتْ قَبْلَ الْفِيلِ بِخَمْسَ عَشْرَةَ سَنَةً .
The Messenger of Allah (Allah's prayers and blessings upon him) married her at the age of twenty five, while Khadija was forty. She was born fifteen years before the Elephant.
This is the most prevalent view, however some scholars like al-Hakim have criticized some narrators and doubted the authenticity of this narration.
The other narrations on their marriage are rather quoting some different circumstances, but not her age.
The second quote of an age in this book appears when he presents some people of al-Kufa there you may find a quote pretending that her marriage age was 28 and her mahr was also quoted which was the same for all the mothers of believers.
أَخْبَرَنَا هِشَامُ بْنُ مُحَمَّدِ بْنِ السَّائِبِ ، عَنْ أَبِيهِ ، عَنْ أَبِي صَالِحٍ ، عَنِ ابْنِ عَبَّاسٍ ، قَالَ : " كَانَتْ خَدِيجَةُ يَوْمَ تَزَوَّجَهَا رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ ابْنَةَ ثَمَانٍ وَعِشْرِينَ سَنَةً ، وَمَهْرُهَا اثْنَتَا عَشْرَةَ أُوقِيَّةً ، وَكَذَلِكَ كَانَتْ مُهُورُ نِسَائِهِ " .
We were infromed by Hisham ibn Muhammad ibn as-Saaib (al-Kulaybi) from his father from ibn Salih for ibn 'Abbas, who said: Khadija, at the day the Messenger of Allah (prayers and blessings of Allah upon him) married her was a woman -literally a girl- of 28 years, and her mahr was twelve 'uqiyah, and so was the mahr of his wives.
Ibn Sa'ad after quoting this added a commentary:
قَالَ مُحَمَّدُ بْنُ عُمَرَ : وَنَحْنُ نَقُولُ وَمَنْ عِنْدَنَا مِنْ أَهْلِ الْعِلْمِ ، إِنَّ خَدِيجَةَ وُلِدَتْ قَبْلَ الْفِيلِ بِخَمْسَ عَشْرَةَ سَنَةً ، وَإِنَّهَا كَانَتْ يَوْمَ تَزَوَّجَهَا رَسُولُ اللَّهِ بِنْتَ أَرْبَعِينَ سَنَةً .
And we and all those we know of from people of knowledge say: Khadija was born 15 years before the year of the Elephant, and she was 40 years old when she got Married to the Messenger of Allah.
So ibn Sa'ad already doubts this. Note that in his al-Itqan as-Suyuti called the narrator chain: Hisham al-Kalby -> His Father-> Abi Salah -> ibn Abbas as the chain of liars! Others call Hisham al-Kalby matrook (somebody left aside, not to take or trust).
But note that this is the only narration here quoting an age and which is narrated on the authority of a sahabi, all others are mostly narrations of Tabi' at-Tabi'in (people who met the people whom met the sahaba) if I'm not mistaking!
Quotes from ibn Kathir's al-Bidaya wa-Nihaya via al-Bayhaqi via al-Hakim
Ibn Kathir in his history called al-Bidaya wa-Nihaya البداية والنهاية quoted a few narrations among those one suggesting that her age was even 25 years which he has taken from al-Bayhaqis ad-Dalail دلائل النبوة whom narrated it via al-Hakim:
قال البيهقي عن الحاكم : قرأت بخط أبي بكر بن أبي خيثمة حدثنا مصعب بن عبد الله الزبيري قال : أكبر ولده عليه الصلاة والسلام القاسم ثم زينب ثم عبد الله ثم أم كلثوم ثم فاطمة ثم رقية وكان أول من مات من ولده القاسم ثم عبد الله ، وبلغت خديجة خمسا وستين سنة ، ويقال : خمسين وهو أصح
Al-Bayhaqi narrated from al-Hakim: I've read in the handwriting of abi Bakr ibn abi Khaythama: we were informed by Mos'ab ibn Abdillah az-Zubayri who said: His elder son (blessings and pece be upon him) was al-Qassim then Zaynab then Abdullah then Um Kalthom then Fatima then Ruqiya and the first who died was al-Qassim then Zaynab then Abdullah then Um Kalthom then Fatima then Ruqiya. His first son who died was al-Qassim then Abdullah and Khadija reached an age of 65 yeras and it was said 50 and this is more correct!
50 - 15 (years they lived together before Muhammad became a prophet) - 10 (years they lived together after Muhammad became a prophet) = 25
This last quote has apparently (only heard it in a video) been adapted by the historian ibn al-Atheer.
Note that some contemporary scholars checked ad-Dalail of al-Bayhaqi and couldn't find this narration while al-Hakim in his Mustadrak has quoted an opinion saying that he doesn't think she has reached the age of 60 when she died (after quoting an other narration on the authority of Hisham ibn 'Urwah of her marriage age being 40 and her death at 65 which he considered as a singularity) and an other narration which has a similarity to the one of ibn Sa'ad on the authority of ibn Ishaaq(which says: she got married to Muhammad at the age of 28 years, died 3 years before hijra and had two children before her marriage). Note that al-Hakim also quoted a hadith saying that Khadija died 1 year before hijra, while most authentic narrations say shed died 3 years before that!
Ibn Kathir also said that al-Bayhaqi has transmitted from al-Hakim an age of 25 or 35 years:
وهكذا نقل البيهقي عن الحاكم أنه كان عمر رسول الله صلى الله عليه وسلم حين تزوج خديجة خمسا وعشرين سنة وكان عمرها إذ ذاك خمسا وثلاثين ، وقيل خمسا وعشرين سنة .
Note that as it seems all the earlier and the majority of the later historians agree that Muhammad was 25 years old at the time of his marriage. However even here there are some single narrations which might need to be checked which even give the impression that Muhammad actually was older than Khadija (35/25) which are quoted in lesser known history books.
Some other information without quotes: Ibn 'Asakir said that Khadija died at an age beyond 55 years.
The statement that she died at an age of 65 was not only quoted by al-Waqdi but by -at least- Hisham ibn 'Urwah هشام بن عروة too. And al-Hakim only criticized the second!
Some related posts:
Is al Hakims Hadith collection Al Mustadrak reliable?
The Historians in the eyes of Hadith-Scholars:
Status of al Waqidi as a narrator?
Four untrustworthy hadith narrators of hadith said by al Nasa'i?
Did Muhammad torture anyone to get info?