Umar bin Khattab reported,

I heard the Messenger of Allah ﷺ say, "Actions are judged only by intentions, and every person will be rewarded according to what he intended. So whoever's migration was for worldly gain or for a woman he sought to marry, his migration is for that which he migrated toward."

Bukhari 1

Sahih

حدثنا الحميدي عبد الله بن الزبير قال حدثنا سفيان قال حدثنا يحيى بن سعيد الأنصاري قال أخبرني محمد بن إبراهيم التيمي أنه سمع علقمة بن وقاص الليثي يقول سمعت

عمر بن الخطاب رضي الله عنه على المنبر قال

سمعت رسول الله ﷺ يقول إنما الأعمال بالنيات وإنما لكل امرئ ما نوى فمن كانت هجرته إلى دنيا يصيبها أو إلى امرأة ينكحها فهجرته إلى ما هاجر إليه

البخاري 1صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Beginning of revelation
Chapter
How revelation began to the Messenger of Allah ﷺ
Numbering
Darussalam 1
Bukhari 1