In their motion for preliminary approval of the settlement, lawyers for the lead plaintiff, Jacqueline Cote, argued that Walmart had discriminated against Ms. Cote because she was married to a woman. They also made the more traditional argument that the company had discriminated against Ms. Cote because she did not conform to the stereotype that women must marry only men.

Although Walmart did not endorse any particular legal theory as part of the settlement, it also did not move to dismiss the case on grounds that the arguments were flawed.

“Some employers, as well as some employee groups, will be wondering if this reflects Walmart’s assessment of where courts might be moving,” said Helen Norton, a professor at the University of Colorado Law School.

Ms. Cote began working as an associate at Walmart in Maine in 1999 and worked continuously at the company there and in Massachusetts through early 2016. In 2004, she married Diana Smithson, another Walmart associate, in Massachusetts, where she lived.

In 2008, Ms. Smithson left the company to become the primary caregiver for Ms. Cote’s mother. Around that time, Ms. Cote began trying to enroll Ms. Smithson in Walmart’s spousal health insurance plan. The company repeatedly blocked her from signing up because of its policy of denying health insurance benefits to same-sex spouses.

In 2012 Ms. Smithson was diagnosed with ovarian cancer, and the couple ran up some $150,000 in uninsured medical expenses over the next few years.

Under the deal, Walmart will fully reimburse current or former employees affected by its previous policy for the applicable out-of-pocket cost of their spouse’s health care from Jan. 1, 2011, to Dec. 31, 2013, if they submit documentation of the costs incurred. The company will also pay 250 percent of out-of-pocket costs for those who submit documentation for expenses of $60,000 or more in health care expenses for their spouse.