Women in command of America’s biggest businesses are reaping rich rewards.

In an unusual reversal of the gender pay gap, female chief executives at some of the largest U.S. companies repeatedly outearn their male counterparts. Last year, 21 female CEOs received a median compensation package of $13.8 million, compared with the $11.6 million median for 382 male chiefs, according to a Wall Street Journal analysis of S&P 500 leaders who held the job a full year.

Women in the corner offices of the biggest U.S. firms made more money than men in six of the last seven years, though the gap has narrowed since 2014. The trend reflects several factors including strong performances at major businesses run by women during recent years, plus the fact that several female CEOs are pursuing tough turnarounds, which boards typically reward.

Another key factor: few women rise to the top of the corporate ladder. Those doing so tend to be superstars who overcome many obstacles before they run an S&P 500 company, according to executive pay and leadership specialists. Boards in search of diversity and high performers are more willing to pay a premium for a successful female CEO, the experts said.

“Boards don’t want to shortchange their female CEO in today’s environment, when pay equality is such an issue,’’ said Robin Ferracone, head of Farient Advisors LLC, which advises board compensation committees.