(Note: Social Security benefits are gender-neutral, but in this article I will refer to the wife as the recipient since statistically this is typically the case.)

Sociologists have a name for folks who divorce after age 50—“gray divorcees”—and their numbers are on the rise in the U.S. In fact, more Americans in this age group now are divorced than widowed, and the number is growing along with increased longevity.

While this is not a happy trend, there is (pardon the pun) a silver lining. It turns out that while the marriages themselves may have ended, certain Social Security benefits from the marriage often survive. Older divorcees need to be aware of these benefits—or else risk losing out on thousands of dollars of lifetime income.

Most people are aware that spouses are entitled to certain benefits under Social Security, based on the employment record of their partner. Many are surprised to learn, however, that divorced spouses may also be entitled to the same Social Security benefits based on the employment record of their former partner. The rules vary slightly. I will first discuss those that apply to currently married couples.

One spouse can claim a spousal benefit after the other has filed for his own retirement benefit. At full retirement age, the claiming spouse will receive 50% of her husband’s primary insurance amount—that is, the retirement benefit due him at full retirement age—as her spousal benefit. Claiming earlier (but not before age 62) results in a reduced benefit. After full retirement age, and while receiving a spousal benefit, a wife can defer her own retirement benefit in order to earn delayed credits, and then at age 70 switch to the increased retirement benefit for the rest of her life. Spouses whose own retirement benefit is less than half her husband’s would continue collecting a spousal benefit for as long as both spouses are alive.

The death of one spouse triggers a second available benefit: the survivor benefit. Upon the death of a spouse, the surviving spouse can receive the deceased’s benefit as their own for the rest of their lives as long as this benefit is greater than the one they are entitled to on their own record. A reduced survivor benefit can be claimed as early as age 60, or the survivor can wait until full retirement age and receive an unreduced benefit (unless her husband took his benefit early). In general, the marriage must have lasted at least nine months and the surviving spouse must not remarry before age 60.

These rules generally describe the benefits available to currently married couples. Most people do not realize, however, that these same benefits are also available to divorced spouses who satisfy a slightly different set of rules.

Divorced spouses who were married for at least 10 years can claim a divorced spouse benefit once their former spouse reaches age 62. If the divorce occurred more than two years ago, the former spouse does not even need to have filed for her own benefit. The other rules governing spousal benefits apply to divorced spouse benefits as well. Remarriage terminates a divorced spouse benefit.

Amazingly, the Social Security rules allow each former spouse to claim a divorced spouse benefit simultaneously (something not allowed to currently married couples). Neither ex-spouse’s benefit will be impacted by the other’s. Perhaps even more amazing is that if a man had multiple marriages that each lasted more than 10 years, each of his ex-wives can receive a divorced spouse benefit and neither the ex-husband or any of the ex-wives’ benefits will be affected as a result. (I’m certain this was not intended when the Social Security rules were first written!)

Divorced spouses are also entitled to survivor’s benefits. Again, the marriage must have lasted at least 10 years and the surviving divorced spouse must be at least age 60 and unmarried. She can remarry after age 60 and continue to receive a survivor’s benefit. While a survivor’s benefit can be claimed as early as age 60, taking it before full retirement age results in a reduction.

Older divorcees need to be aware of the potential Social Security benefits they may be entitled to as a result of a former marriage. Given the complexity of the applicable rules, divorced boomers should seek the advice of financial planner with expertise in this area. Engaging a good advisor will be well worth the cost given the potentially significant additional lifetime at stake.

Originally published on NerdWallet’s Advisor Voices