After the conquest of Hamadan the Muslims had appointed Khusrau Shanum the Governor of the District under the suzerainty of the Muslims. The Governor betrayed his trust, and when the Muslims were campaigning against Isfahan, he acted in a way prejudicial to the interests of the Muslims.
Umar ordered a campaign against Hamadan and Rayy. The command was entrusted to Nuaim bin Muqarrin. Some time in January 642 Nueim bin Muqarrin marched with his forces from Nihawand to Hamadan. The city was invested. The Persians were defeated and the city was recaptured. Khusrau Shanum was deposed and another Governor was appointed in his stead.
Leaving a detachment at Hamadan, Nuaim proceeded to Qaxween. At Waj Ruz a few miles from Qazween the Muslims met a large Persian army led by Isfandiar, a brother of the late Rustam. A bloody battle followed in which the Persians were defeated and driven back. Some Persians fled to Rayy and some to Azarbaijan.
From Waj Ruz the Muslim army marched to Rayy. The city of Rayy was strongly fortified and heavily defended. The Muslims invested the city. The siege proceeded for about a week. One night Muslims discovered an opening in the city walls through which the Muslim forces entered. Taken by surprise the Persian garrison surrendered. Rayy was sacked and a considerable booty was taken. The Persians agreed to pay Jizya and peace was restored.
Nuaim established himself at Rayy and sent columns under his brother Suwaid to subdue the adjoining region. Suweid marched to Demawand where after some show of resistance the Persians surrendered. From Demawand the Muslim army proceeded to Damaghan. There was a confrontation but the Persians were beaten, and they surrendered agreeing to pay Jizya. Then the Muslims marched to Gurgan. Here no resistance was offered, and the Persians surrendered agreeing to pay Jizya.
By April 642 the Rayy campaign had come to a successful close. By the conquest of Isfaban and Ravy the Muslims had succeeded in driving a broad wedge in the centre of Persia, severing the north from the south. The Persian empire now lay bleeding.