Hadithcore
Sahih al-Bukhari, 2804
sahih

Narrated `Abdullah bin `Abbas:

That Abu Sufyan told him that Heraclius said to him, "I asked you about the outcome of your battles with him (i.e. the Prophet (ﷺ) ) and you told me that you fought each other with alternate success. So the Messengers are tested in this way but the ultimate victory is always theirs.

حَدَّثَنَا يَحْيَى بْنُ بُكَيْرٍ، حَدَّثَنَا اللَّيْثُ، قَالَ حَدَّثَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، عَنْ عُبَيْدِ اللَّهِ بْنِ عَبْدِ اللَّهِ، أَنَّ عَبْدَ اللَّهِ بْنَ عَبَّاسٍ، أَخْبَرَهُ أَنَّ أَبَا سُفْيَانَ أَخْبَرَهُ أَنَّ هِرَقْلَ قَالَ لَهُ سَأَلْتُكَ كَيْفَ كَانَ قِتَالُكُمْ إِيَّاهُ فَزَعَمْتَ أَنَّ الْحَرْبَ سِجَالٌ وَدُوَلٌ، فَكَذَلِكَ الرُّسُلُ تُبْتَلَى ثُمَّ تَكُونُ لَهُمُ الْعَاقِبَةُ‏.‏

References2 variants
In-Book Reference
Book 56, Hadith 21
USC-MSA web (English) reference
Vol. 4, Book 52, Hadith 60 (deprecated numbering scheme)