Lopetegui was appointed in June but five defeats in seven games, the last of them a 5-1 thrashing by Barcelona on Sunday, have convinced Madrid to make a change.
Santiago Solari, the club's B team coach, has been put in temporary charge.
The decision was announced following a meeting of Madrid's board of directors on Monday night.
A club statement read: "This decision, adopted from the highest level of responsibility, aims to change the dynamics of the first team, when all the objectives of this season are still achievable.
"The Board of Directors understands that there is a great disproportion between the quality of the staff of Real Madrid, which has eight players nominated for the next Golden Ball, something unprecedented in the history of the club, and the results obtained to date."
Solari will lead the first team from Tuesday and is expected to be in charge for the Copa del Rey game against Melilla on Wednesday.
The Argentinian could also remain in post for Saturday's La Liga match at home to Real Valladolid.
In his two seasons with Castilla, Solari oversaw them finishing 11th and eighth in the Spanish third tier.
Lopetegui's time as coach of Real Madrid lasted just 139 days, with his decision to join the club also costing him his job as Spain boss at last summer's World Cup.
Real have managed only one win in their last seven matches, sit ninth in La Liga, and earlier this month went more than eight hours without a goal.
Antonio Conte is the frontrunner to be Lopetegui's permanent successor, although early talks have not gone smoothly, according to reports.
Belgium coach Roberto Martinez and former Madrid midfielder Guti have also been linked with the position.
More about: Real-Madrid