Majka, who was third overall in the 2015 edition of this race, won on a solo breakaway up the final special-category ascent.
Lopez finished the 129.4-kilometer (80.4-mile) stage starting in Alcala la Real in 3 hours, 34 minutes, 51 seconds.
Magnificent Majka climbs to Vuelta stage 14 win as Froome protects lead
Astana rider Miguel Angel Lopez was second on the day, 27 seconds behind Majka, at the end of an exacting 175 kilometre ride from Ecija to Sierra de La Pandera which featured narrow roads in its final four kilometres, with the steepest sections at 15 per cent.
Four-time Tour de France victor Froome needed help from two Sky teammates to limit the time lost after he tumbled to the asphalt twice on the stage's descent to the finish line.More news: Defending champion Kerber beaten by Japanese teenager at US Open
Nibali attacked Froome on the climb, but the four-time Tour de France victor kept him close and then closed the gap with 2 kilometers (1.2 miles) left on the punishing final ascent. "It's incredible. I came in this race with confidence but I never expected something like this". "Now I'm just so happy, not because I won, but for my teammates", Majka said. I had good legs and Patrick Konrad did a really good job with me in the break.
Saturday's stage was the first of two back-to-back summit finishes which will have a big say in whether Froome succeeds in becoming the first rider in 39 years to win the Tour de France and La Vuelta in the same year. The Dutchman Wilco Kelderman (Sunweb) completes the provisional podium in 2 min.More news: Tillerson distances himself from Trump's Charlottesville response
Vincenzo Nibali is still 59 seconds behind Froome in second place, followed by Esteban Chaves.
Riders face another tough test in the southern mountains on Sunday.More news: 'Hats off to Tamim and Shakib'
The 2017 Vuelta de España finishes in Madrid on September 10.