A closely-watched and long-debated piece of energy legislation is set to become law after passing through both legislative chambers with the governor's endorsement.