Gallego's departure was confirmed by Espanyol on Monday and the announcement of Machin's arrival on a two-year deal followed soon after.
The club are 19th in LaLiga after a poor start to the new season, though they have taken four points from two Europa League games.
Fi de l'etapa de David Gallego al RCD Espanyol de Barcelona: https://t.co/nRtKiqiJEL— RCD Espanyol de Barcelona (@RCDEspanyol) October 7, 2019
¡Muchas gracias por todos estos años en el club, David! ¡Buena suerte en el futuro!#EspècieEnExpansió | #RCDE | #Volem | #EspanyoldeBarcelona pic.twitter.com/B8K9MFT34E
"The club has taken this decision as a result of the performance of the first team and with the clear idea to redirect the current situation of the team in LaLiga," said an official statement.
Gallego was only appointed as head coach by the club in June, earning promotion from Espanyol's B side when Real Betis lured Rubi away from RCDE Stadium.
Former Girona coach Machin was sacked by Sevilla in March after they suffered a shock Europa League last-16 exit to Slavia Prague.
Machin's first game in charge of Espanyol will be at home to Villarreal on October 20 and they travel to Ludogorets in the Europa League four days later.