Luton had looked on course to land a thoroughly deserved draw after two errors from Raya had seen them hit the front – only for the Gunners to rally and win it 4-3 at the death.
Raya embraced Rice at the full-time whistle after Kai Havertz had earlier drawn the visitors level in what proved to be a thrilling contest at Kenilworth Road.
Raya, whose role as Arteta’s number one continues to be in the spotlight with Aaron Ramsdale warming the bench, then gifted two goals to Luton in the space of eight minutes as Elijah Adebayo and Ross Barkley turned the game on its head.
Havertz appeared to have salvaged a point for Arsenal but they pushed on to the last and £105million summer signing Rice nodded in a fine Martin Odegaard cross to wrap up the victory.
Having seemingly spent more time on his back than on the ball, Martinelli silenced a raucous home crowd with the opening goal.
Luton had started aggressively but played their part in falling behind as Amari’i Bell’s overhit backpass was put out for a throw by Thomas Kaminski. Jesus was quick off the mark to find Bukayo Saka, who laid the ball across for Martinelli to scuff home with their first effort on target.
The home fans would not be kept quiet for long, however, as Osho easily drifted away from the attentions of Martinelli to head home Alfie Doughty’s corner five minutes later.
In what was proving to be a mixed bag of a first half for Martinelli, he almost put Arsenal back in front after the half-hour having been slipped in by Jesus but his effort was superbly stopped by Kaminski.
The Hatters goalkeeper was on hand again soon after to push away a Saka strike after the England forward cut inside with ease.
Luton, though, could not make it into the half-time break on level terms as Ben White stood up a cross to the back post where Jesus headed in from close range.
Less than five minutes after the restart, however, the hosts equalised for the second time as Adebayo rose to head in another Doughty corner with Raya coming off his line and getting nowhere near the ball.
The roof came off Kenilworth Road as Luton hit the front for the first time soon after, Raya again at fault as Rob Edwards’ experienced heads combined with Andros Townsend feeding Barkley, whose low shot squirmed in under the Spanish goalkeeper.
All of Luton’s hard work was undone just three minutes later as Arsenal this time drew level, Havertz finishing off after a long ball had been steered into his path by Jesus.
The Gunners wanted a penalty after Saka was challenged in the box by Osho and Gabriel Magalhaes went down as he jostled for a cross but referee Sam Barratt pointed for a corner following a VAR check.
It was Arsenal pushing for a late winner and Kaminski turned a Havertz header over at the end of a slick move.
Rice would ultimately make the difference as Arsenal were patient in their build-up, Odegaard swapping passes with substitute Oleksandr Zinchenko before crossing in for Rice to head home.