BARCELONA, Spain (AP) — Real Madrid and Barcelona started their Copa del Rey campaigns with surprisingly hard-fought wins over lower-tier teams on Wednesday, while third-division Atlético Baleares eliminated a second topflight side by beating Celta Vigo 2-1.

Madrid needed two late goals to beat Alcoyano 3-1, which one year before had eliminated the powerhouse in the same round of 32. Earlier, Barcelona had to come from behind to beat third-tier Linares Deportivo 2-1.

Defender Éder Militão put Madrid ahead in front of 4,800 fans at El Collao Stadium. But the hosts created scoring chances throughout and pulled level in the 66th minute when Dani Vega cut back to avoid both Casemiro and Militão before curling home.

Marco Asensio put Madrid back in charge in the 76th when his shot hit a defender, leaving Alcoyano's goalkeeper no chance to save. Fellow substitute Isco Alarcón ensured the win two minutes later.

BARCELONA ADVANCES

Barcelona forwards Ousmane Dembelé and Ferran Jutglà scored to complete the team's comeback against Linares.

Dembelé went on at halftime and canceled out Hugo Díaz’s 19th-minute goal for Linares with a strike from outside the area to level in the 63rd.

Jutglà netted the winner six minutes later to save Barcelona from an embarrassing exit from the cup in southern Spain.

Dani Alves played his first match since returning to Barcelona. The 38-year-old Brazil right back played for Barcelona from 2008 to 2016, helping it win 23 titles including three Champions League trophies.

ANOTHER UPSET

Baleares, which had already stunned Getafe 5-0 in the previous round, got two goals from Manel Martínez to upset Celta.

Martínez gave the club from the Mediterranean island of Mallorca the lead in the 17th with a header from a quickly taken corner kick.

Substitute Brais Méndez pulled Celta level in the 67th, only for Martínez to head in a cross for the 76th-minute winner.

OTHER RESULTS

Denis Cheryshev scored in stoppage time to give Valencia a 2-1 win at second-division side Cartagena.

Mikel Oyarzabal scored twice to give Real Sociedad a 3-2 win at Leganés, while Real Betis beat Valladolid 3-0 and Mallorca rallied to beat Eibar 2-1.

___

More AP soccer: https://apnews.com/hub/soccer and https://twitter.com/AP_Sports