Both parties pledged not to compete with one another when they face France's newly elected President on June 12 and 19.
France's parliamentary elections - or the third round as they are known - decide which députés (MPs) sit in the National Assembly. This is important as laws can only be passed with the Assembly's support, plus the number of seats a party wins determines its public funding.
If Macron's La République en Marche party does not get a majority in the Assembly, it will be more difficult for him to pass his pro-business laws, including plans to push back the retirement age.
Monday's deal with the greens signifies that Mélenchon, who finished third in the first round of France's presidential election, is hoping to stage a comeback by forming a coalition of left-leaning parties.
Adrien Quatennens, a lawmaker with La France Insoumise (LFI), called Mélenchon's agreement with the greens a "historic moment".
Under it, the environmental party will field candidates in 100 districts where Mélenchon's La France Insoumise (France Unbowed) party is not running.
This is to avoid splitting the vote, strengthening each party's electoral chances.
The greens, in exchange, will back Mélenchon as Prime Minister, if their coalition wins a parliamentary majority.
Early polls ahead of the June 12-19 elections suggest Macron is likely to achieve a majority, but alliances on the left and right could put a stop to that.
The aims of the green-left coalition include lowering the retirement age to 60, raising the minimum wage and capping prices on essential products.
Mélenchon is also in talks with the Communist and Socialist parties to make a deal.
Getting 22% of the vote in the first round of France's presidential election gave Mélenchon leverage to try and rally other parties on the left before the legislative vote.
But the socialists are divided as to whether they should join the coalition.
Some figures in the party have condemned Mélenchon's stance toward the EU, particularly that France should contest what he calls the bloc's free-market regulations.