Lopetegui, 52, was announced as Madrid coach just before the start of the World Cup in June, with Spanish federation president Luis Rubiales reacting by immediately sacking him. His first game in charge of Madrid was a 4-2 defeat to neighbours Atletico Madrid in the UEFA Super Cup. Lopetegui lasted just 14 matches in total, with six wins, two draws and six defeats.
Former player and Castilla reserve team boss Santiago Solari has been put in caretaker charge, the club said.
A club statement read: "Real Madrid's board met today on 29 Oct 2018 and has agreed to end the contract linking coach Julen Lopetegui with the club. This decision has been taken to change the dynamic in which the first team finds itself, when all the objectives for the season are still achievable.
"The board understands that there is a big difference between the quality of Real Madrid's squad, which has eight players nominated for the next Ballon D'Or, something without precedent in the history of the club, and the results obtained to date. The club thanks Julen Lopetegui and all his staff for their effort and the work done, and wishes them all the best in their professional careers."
In a statement to Spanish news agency EFE, Lopetegui said: "After the decision adopted by the board of directors of Real Madrid today, I want to thank the club for the opportunity that gave me to coach the team.
"Thanks to the players for their effort and their work, as well as to each and every one of the club's employees, for the great treatment during my time with the club. And, of course, my gratitude to the fans for their encouragement. Best wishes for the remainder of the season."
Sunday's embarrassing defeat to Barcelona was the end for Lopetegui following a run of dire form, including a 3-0 La Liga reverse at Sevilla, a 1-0 loss at CSKA Moscow in the Champions League and a 2-1 defeat at home to Levante in La Liga. Lopetegui took Madrid training behind closed doors on Monday amid strong rumours he would be sacked and Madrid then confirmed his departure later that day.
Lopetegui's Real Madrid Timeline
June 12 - Accepts an offer to replace Zinedine Zidane as Real Madrid coach after the World Cup, only to be sent home from Russia by Spanish FA president Luis Rubiales just two days before La Roja's opening game.
June 14 - Presented as Real Madrid coach by Florentino Perez and says: "Yesterday was the saddest day of my life, since the death of my mother, but this is the happiest day."
July 18 - Not involved in the decision making as Madrid's all-time record goalscorer Cristiano Ronaldo is sold to Juventus for €100m, with a plea late in the window for a replacement forward met with the signing of former reserve Mariano Diaz from Lyon.
Aug. 15 - Loses first official game as Madrid coach 4-2 to neighbours Atletico Madrid in the UEFA Super Cup.
Oct. 20 - Watches his team go past the eight-hour mark without scoring a goal, with Marcelo's strike in the second half not enough to stop a 2-1 home defeat to Levante, which is followed by ringing whistles around the Bernabeu.
Oct. 28 - Says the season can still be turned around despite a 5-1 Clasico defeat at Barcelona that leaves Madrid with one point from five La Liga games.
Speaking after the 5-1 loss at Camp Nou, Sergio Ramos said: "Results determine a lot whether a coach stays. But it is not our decision, it comes from above. We have heard nothing. So we will let the hours pass, and what must happen will happen."
After winning the Champions League trophy in four of the past five seasons, Madrid lost Ronaldo in July and Zidane stepped down as coach, suggesting as he left that the squad needed a big shake-up.
With president Florentino Perez saving money ahead of a €400 million-plus stadium renovation project, and reported transfer targets Neymar and Kylian Mbappe staying at Paris Saint-Germain, Madrid did not sign a big-name replacement for Ronaldo.
Instead, around €100m was invested in youngsters, including Vinicius Jr., 18, from Brazil and Spain right-back Alvaro Odriozola. Goalkeeper Thibaut Courtois, who joined from Chelsea, was the main first-team arrival.
As a player, Lopetegui was a goalkeeper who had spells as a back-up at both Madrid and Barcelona, and he also played for Rayo Vallecano and Logrones.
He began his coaching career at Rayo, moved to the Castilla team then coached Spain's under-19s, U20s and U21s. He spent 18 months at Porto before leading the Spain national team through qualification for the 2018 World Cup.