Espanyol said Rubi, 49, had paid a release clause to leave the Catalan club. He replaces Quique Setien, whose departure from Betis by mutual consent was announced in May after a two-year tenure.
Former midfielder Gallego was previously in charge of the reserve team at Espanyol.
Seville side Betis ended the season 10th and three points behind seventh-placed Espanyol, who took the final Europa League qualification berth.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
(Reporting by Alan Baldwin in London, editing by Christian Radnedge)
