The agreement, which the American states and Canadian province will sign Thursday, has been years in the making.