Labor has struck an eleventh-hour deal with the Greens.