The minnows fought gamely in the first half but Joselu put Madrid ahead with a penalty early in the second, with Brahim Diaz and Rodrygo goals expanding Madrid’s lead.
Madrid defender Nacho Fernandez put through his own net in stoppage time to give Arandina a consolation goal which delighted supporters at their packed 6,000-capacityB El Montecillo stadium.
Elsewhere Atletico Madrid progressed with a 3-1 win at third-tier Lugo after Memphis Depay struck twice, while Real Betis were knocked out in a 1-0 defeat by Alaves.
Surprise La Liga title challengers Girona beat second-division side Elche 2-0.
Arandina battled well to frustrate Madrid in a surprisingly even first half in the province of Castile and Leon, north of the Spanish capital.
Carlo Ancelotti started Eduardo Camavinga, returning after a knee ligament injury which saw him miss nearly two months.
Otherwise, the Italian largely deployed a combination of reserve and youth players, handing Turkish playmaker Arda Guler his first appearance since joining Madrid this summer from Fenerbahce.
Guler came closer than anyone to scoring in the first half, striking the post with a rasping free-kick and playing with freedom to roam.
Madrid took the lead from the spot early in the second half after the excellent Diaz was tripped by Zazu as he ran into the area, with Joselu dispatching a firm, low penalty.
Diaz added the second moments later after the ball broke loose to him and he fired it home across Arandina goalkeeper Adrian Alvarez.
Joselu missed a good chance to extend Madrid’s lead further before substitute Rodrygo stroked in the third in stoppage time from Diaz’s cross.
Arandina got the goal their performance deserved at the death when Nacho deflected Raly Cabral’s cross into his own net.