The 30-year-old has joined on loan for the rest of the campaign.
The one-time Northern Ireland international was told he can leave the Stadium of Light if a suitable offer came in ahead of the deadline and both the Millers and Rovers made their pitch to sign him.
Rovers - without a win in League One so far this season and propping up the table - were handed a welcome boost with the news that the club's board had made more funds available ahead of the transfer deadline to aid manager Richie Wellens's quest to bring in a couple of new recruits in the final third.
But the Millers won the race to sign him, announcing his arrival just prior to the deadline.
Grigg will provide healthy competition for Freddie Ladapo, Joshua Kayode and Michael Smith, with the Millers managing to retain the services of the latter despite much speculation over his future through the the summer.
Grigg's arrival followed shortly after the departure of defender Curtis Tilt, who has headed back across the Pennines to join League One rivals Wigan Athletic on loan for a third time
The former Blackpool centre-back, 30, had two stints on loan at the Latics in 2020-21 - having failed to establish himself during his time at Rotherham.
He made 36 appearances for the Lancashire club last term.
Tilt joined the Millers for an undisclosed fee in January 2020, but made just one senior appearance for the club in the 2019-20 season - curtailed due to the Covid-19 pandemic, while a glute problem ensured that he had to bide his time for his debut.
A hamstring injury hindered Tilt's progress in pre-season and he has now completed another temporary move to Wigan, where he will remain for the rest of the campaign.