Russian international Denis Cheryshev opened the scoring in Andalusia, but shouldn't have been on the field as he was due to serve a one-game ban in the competition after picking up three yellow cards whilst on loan at Villarreal last season.
Cheryshev was replaced a minute into the second-half by Mateo Kovacic.
"Clearly we didn't know. Villarreal and the federation hadn't warned us," said Madrid boss Rafael Benitez.
"When we knew we substituted him to show good faith."
More From This Section
However, the result could yet prove meaningless if Madrid are proved to have fallen foul of the competition's rules with Cadiz president Manolo Vizcaino confirming his club will launch a formal complaint.
"We have decided to report the ineligible line-up," he said. "It hurts us to do so with a friendly club, but the decision taken has been firm and unanimous."
Real Madrid director of institutional relations Emilio Butragueno also laid the blame at the Spanish Football Federation and Villarreal for not informing Madrid of the ban.
Second division side Osasuna were thrown out of the Cup earlier this season for fielding an ineligible player in their second round tie against Mirandes.
The error is the latest blow for Madrid after a disastrous couple of weeks that has seen the 10-time European champions fall six points behind La Liga leaders Barcelona after being hammered 4-0 at home by Barca 11 days ago.
It is also not the first time Madrid have been caught out by an administrative problem this season after the signing of Manchester United goalkeeper David de Gea fell through as the clubs missed the deadline for the paperwork to be filled.
Luis Enrique left Lionel Messi out of his 16-man squad, whilst Neymar and Luis Suarez remained on the bench as Barca's mix of youngsters and veterans proved way too strong for Villanovense after they had held out bravely for a 0-0 draw in the first leg five weeks ago.
Dani Alves's dipping long range effort which took Villanovense 'keeper Jose Antonio Fuentes by surprise opened the floodgates after just four minutes.
Ramirez then ended his 12-month wait for a goal with the Barca senior side as he slammed into the roof of the net after capitalising on a fluffed clearance by Fuentes.
However, Ramirez eased any Barca nerves two minutes later with a cool finish from Aitor Cantalapiedra's pass.
Both Ramirez and Munir El Haddadi failed to score in the two months that they shared deputising for Messi whilst the Argentine was sidelined by a knee ligament injury recently.
But against weaker opposition they showed their potential as El Haddadi headed home Jeremy Mathieu's cross to make it 4-1.
Valencia, who announced the appointment of Gary Neville as coach earlier on Wednesday, came from behind to beat Barakaldo 3-1 in the first leg of their fourth round tie.
Gary's brother Phil was part of the caretaker coaching staff in the Basque country as goals from Joao Cancelo, Jose Luis Gaya and Dani Parejo put Los Che well on course for the last 16.
Sevilla cruised to a 3-0 win at Logrones, whilst there were also first leg wins for Real Betis, Rayo Vallecano, Celta Vigo and Deportivo la Coruna.