When Gov. Charlie Baker returns to the State House on Monday, he will have on his desk legislation to ensure that men and women are paid the same for comparable work, one of six major bills he wanted lawmakers to send him before formal sessions end July 31.

The House and Senate on Saturday afternoon both unanimously enacted the compromise bill, after the branches settled disagreements over details on Thursday.

The compromise legislation (S 2119) most closely resembles the version approved unanimously last week by the House, which business organizations like Associated Industries of Massachusetts (AIM) and the Massachusetts Business Roundtable had supported, House and Senate officials said.

"This bill finally recognizes that pay inequity is a problem," said Sen. Patricia Jehlen, who has filed pay equity legislation over several sessions. "It doesn't solve the problem, but it removes many barriers which we know have kept women from achieving equity."

The bill prohibits discrimination on the basis of gender in the payment of wages for comparable work "unless the variation is based upon a mitigating factor" including seniority, education, training, experience, or a bona fide merit system like one that measures earnings by sales.

It also encourages businesses to evaluate their own pay practices and would allow self-evaluations to be used as an affirmative defense in a pay discrimination claim, if they were conducted within the previous three years and the employer could demonstrate "reasonable progress" toward closing pay differentials. The evaluation and any steps taken to close a gap could not be used as evidence of a violation of pay equity.

"This is an historic day," Sen. Karen Spilka said, introducing the bill prior to the vote that sent it to Baker's desk. "This will be one of the strongest, if not the strongest, (pay equity laws) in the nation. It has support now from the business community as well."

The House enacted the bill 151-0 and the Senate did so 40-0.

A study from the Institute for Women's Policy Research reported earlier this year that the state's earnings ratio placed Massachusetts in 18th place nationally for pay equity and, without changes, the state's wage gap is expected to persist until 2058.