Castex's move cleared the way for a long-awaited cabinet overhaul by Macron who after his re-election in April has said his new government team should be more "concentrated", with less ministers.
Macron, who needs to send a signal he has heard the frustrations of voters expressed in low turnout and big support for the radical far-right and far-left, has said he was looking for someone with green and social policy credentials as prime minister.
His allies have said he will most likely appoint a woman, who would be the first since Edith Cresson briefly occupied the top job during the presidency of Socialist leader Francois Mitterrand in the early 1990s.
Current Labour Minister Elisabeth Borne is widely expected to get the job.
Such a profile could help counter the challenge mounted by hard-left veteran Jean-Luc Melenchon who reached a strong third place in the presidential election, allowing him to rally a broad coalition of France's left-leaning parties in the June 12-19 parliamentary vote.