A rabbi came to the Prophet ﷺ and said, "Muhammad," or perhaps he said, "Abu Qasim, on the Day of Resurrection Allah Most High will hold the heavens on one finger, the earths on one finger, the mountains and the trees on one finger, the water and the moist soil on one finger, and the rest of creation on one finger. Then He will shake them and say, 'I am the King, I am the King.'"The Messenger of Allah ﷺ laughed in wonder at what the rabbi had said, affirming its truth, and then he recited, "They have not appraised Allah with the appraisal due to Him, when the whole earth will be within His grip on the Day of Resurrection, and the heavens will be rolled up in His right hand. Glory be to Him, and exalted is He above what they associate with Him" [Zumar 39:67].
جاء حبر إلى النبي ﷺ فقال: يا محمد أو يا أبا القاسم، إن الله تعالى يمسك السماوات يوم القيامة على إصبع، والأرضين على إصبع، والجبال والشجر على إصبع، والماء والثرى على إصبع، وسائر الخلق على إصبع، ثم يهزهن، فيقول: أنا الملك، أنا الملك، فضحك رسول الله ﷺ تعجبا مما قال الحبر، تصديقا له، ثم قرأ: {وما قدروا الله حق قدره والأرض جميعا قبضته يوم القيمة والسموات مطويت بيمينه سبحنه وتعالى عما يشركون}. [الزمر: ٦٧].
Bukhari narrated it in the Book of Monotheism (7414), and Muslim narrated it in the Description of the Day of Judgment, Paradise, and Hell (2786), both of them through the route of Mansur, from Ibrahim, from Ubayda Salmani, from Abdullah bin Masud, who mentioned it. The wording given is that of Muslim.