Before Mitt Romney retired from Bain Capital, the enormously profitable investment firm he founded, he made sure to lock in his gains, both realized and expected, for years to come.

He did so, in part, the way millions of other Americans do — with the tax benefits of an individual retirement account. But he was able to turbocharge the impact of those advantages and other tax breaks in his severance package from Bain in a way that few but the country’s super-rich can ever hope to do.

As a result, his IRA could be worth as much as $87 million, according to his estimates, and he can continue to earn tax-advantaged income from Bain more than a decade after he formally left the firm.

The Republican presidential nominee has been “scrupulous” about observing the tax code, said Romney campaign spokeswoman Michele Davis. “His income is reported and taxed in full compliance with U.S. law, and he has paid 100 percent of what he has owed.” She added that the financial holdings of Romney and his wife, Ann, are managed by a blind trust the Romneys do not control.

Romney’s former colleagues say his retirement package is a well-justified reward for a chief executive who built Bain from scratch in 1984 into a financial powerhouse that backed business successes such as Staples and the Sports Authority.

The structure and tax treatment of his retirement, including the IRA, was legally sound and appropriate, they say, adding that he has earned less money over his career than some other top private-equity executives, who earned billions of dollars during the same period.

Details of Romney’s retirement assets are somewhat vague because he has released only one year of full tax returns and declined to provide additional specifics about his personal finances. But interviews with Bain executives and accounting professionals show that he was able to take advantage of tax benefits in innovative ways open only to a narrow slice of extremely affluent people — mostly those who work in private-equity firms and other investment partnerships.

His severance package, for instance, allowed him to continue sharing in the profits of the company as if he were still a partner managing it, according to his 2010 tax return and interviews with present and former Bain executives. And because he benefited from the firm’s investments as if he were an active Bain partner, he paid taxes at a lower rate on these earnings than if they were treated as ordinary retirement income. Romney negotiated the package when he was leaving the firm, Bain executives said, while he set up his IRA long before.

IRAs were established by Congress nearly 40 years ago to help people save for their retirement. Under the law today, individuals may contribute up to $5,000 per year and employers may contribute up to $50,000 a year to an employer-sponsored IRA. The money is invested, and the investments grow tax-free until retirement. There is no limit on how much money an IRA can earn tax-free.

What determines an IRA’s growth is the performance of the investments, and Bain enabled Romney, its other employees and its partners to score big on that front. It was not uncommon for senior Bain executives to accrue IRAs valued at tens of millions of dollars, according to former and present company employees, by buying into Bain investments at very low prices and then reinvesting the returns in other low-priced Bain investments after the initial investments appreciated.

When Romney was chief executive, Bain set up Simplified Employee Pension IRAs, or SEP-IRAs, under which the company contributed up to $30,000 a year to employees’ retirement accounts, according to people familiar with the program. Many of the employees decided to use this contribution to buy stock in the companies that Bain had acquired in the course of its business as a private-equity firm.

Bain executives encouraged such IRA investments. They demonstrated to Bain’s outside clients, who were also investing in the stock of these acquired companies, that Bain employees were putting their money where their mouth was and sharing in the risk with outside investors. The co-investment strategy was good for building relationships with clients. “Employee investing has always been an essential part of the culture of the firm,” said Bain spokesman Alex Stanton.

Like other IRA investors, Romney will pay a 35 percent tax on the funds in his account when he ultimately withdraws them, said Davis, the Romney campaign spokeswoman. Until then, he can use the money in the account to buy and sell stock and other assets, repeatedly re­investing the money inside the IRA, without having to pay tax rates of up to 40 percent for short-term capital gains. That’s a huge benefit, tax experts say.

Romney’s IRA growth could be dramatic, in part, because he, like other Bain employees, was given access to a type of shares in Bain-backed companies that were often private and low-valued when the employees bought in and then were managed by Bain for growth and an eventual sale or public share offering that would maximize shareholder value.

These “A-shares” were priced by Bain at a fraction of another category of stock known as “L-shares,” which functioned like preferred stock, paying dividends and getting priority for payouts. The A-shares, or common shares, were riskier and thus priced lower, so it was possible that a relatively small IRA in­vestment could buy significant amounts of the A-shares in some companies. The use of a dual-share structure is not unusual in the financial industry, and under financial accounting rules the A-shares must reflect a true market value of the underlying assets. Often, the value of these initially cheap A-shares soared, along with the company’s value.

Consider the example of Physio-Control, which was bought by Bain in 1994. The company, a maker of defibrillators, saw its business take off in the following years, with Bain’s initial investment multiplying 21 times. Under the dual-share structure, the rewards were heavily tilted toward the A-shares. The value of an A-share purchased in 1995 multiplied 445 times in just three years, according to a person familiar with the transaction who spoke on the condition of anonymity. In other words, a $10,000 investment in Physio-Control A-shares would in theory have returned $4.45 million.

Not all deals worked out so well. Bain bought US Synthetic, a maker of bits used in oil and gas exploration, in 1998. By the time the company was sold in 2004, the original Bain investment had multiplied a modest 1.2 times. Under the terms of the company’s dual-share structure, A-shares lost all their value.

By leveraging a series of successful A-share investments, taking profits and reinvesting the money into new A-shares, a Bain IRA fund could easily accumulate millions of dollars without any tax penalty. On the disclosure statements Romney files as a candidate for federal office, he reports his financial holdings and values them by assigning a dollar range to each one. By adding these values together, The Washington Post calculated that the holdings in his IRA were worth between $20 million and $102 million in 2011. The total range shifted downward this year, with Romney valuing the holdings in his IRA at between $17 million and $87 million.

Romney has not disclosed all the assets he used to build his IRA.

In explaining the growth of his account, Romney campaign of­ficials do not dispute The Post’s analysis but note that he had been eligible to contribute to IRA accounts since he entered the work force in 1975 and that the years since then have often been times of strong economic growth.

That does not mean the size and growth of such IRAs are not controversial. Michael Graetz, who served in the Treasury Department under President George H.W. Bush, said massive IRAs such as Romney’s do not reflect the intent of the laws that created the accounts as a way to help working Americans reach financial security.

“One need not have $100 million in an IRA in order to accomplish retirement security,” said Graetz, who teaches tax and retirement policy at Columbia Law School. “The law deliberately set limits in order to restrict the revenue losses to the Treasury.”

Another tax expert, Edward Kleinbard of the University of Southern California, who reviewed the prices of some A- and L-shares, said Bain may have undervalued the A-shares, providing a benefit to insiders. Kleinbard, a Democrat and former chief of staff of the Congressional Joint Tax Committee, said the valuation of such shares should reflect real market prices.

But Jack Levin, a tax lawyer who has represented Bain, said the share prices at Bain were worked out “by all the investors at arm’s length based on the company’s prospects and economic condition at the time of the investment.”

He said the increase in the value of Romney’s IRA reflected business smarts, not questionable investment practices.

“There is nothing magical about it,” Levin said. In the years that Romney ran Bain, the company earned more than a 50 percent return on investment on average each year. Even a lower rate of return, 26 percent a year, combined with a regular investment of new funds in the account would give Romney “more than $100 million in his IRA account today,” according to Levin, a lawyer at Kirkland & Ellis.

He noted that there was nothing improper about amassing so much wealth. “There is nothing in the tax law that prohibits an IRA from earning as much as the sponsor’s investment acumen allows him or her to earn,” he said.

Another way in which tax rules have favored Romney’s post-Bain financial situation is through the treatment of his severance package from Bain. Again, he benefited from a tax break in a way that is available to very few. His retirement earnings receive what is called the “carried interest” deduction. That’s an accounting classification that treats certain income from private-equity firms and other partnerships as capital gains and taxes it at a rate of 15 percent, rather than as ordinary income at 35 percent.

Here’s how carried interest works: Most private-equity firms charge their clients fees known as “2 and 20” — 2 percent of an investment fund’s overall assets and 20 percent of any profits. Managers generally declare the 2 percent management fee as ordinary income, meaning they pay ordinary income and payroll taxes on the money. But most private-equity managers say the 20 percent share of profits, the “carry,” is an investment and thus should be taxed at the capital gains rate.

Defenders of carried interest say the lower tax rate provides fund managers with an incentive to take smart risks, because they share in the investment with their clients. Opponents say it is a loophole that ought to be closed.

Romney’s 1999 severance package was structured to take advantage of the carried-interest treatment. It took nearly a year of negotiations to arrange that package after he left Bain in 1999 to run the Salt Lake City Winter Olympics, Bain insiders say, and he did not formally resign as chief executive until he had negotiated the deal.

The result of the negotiations was a deal that allowed Romney to continue sharing in the profits of the company for 10 years in the same way that active managers received compensation. These carried-interest profits would be taxed at a 15 percent rate, less than half the rate that retirees might pay on other income, including payouts from pensions, IRAs and stock options.

Under the terms of the retirement package, as described by Romney and Bain executives, he would benefit from Bain business deals made through Feb. 11, 2009 — 10 years to the day after he left Boston to run the Olympics.

He would receive the 2 percent management fee as well as a share of the carried-interest profits that Bain made from acquiring and later reselling companies. Bain declined to say how large the share was, but a person familiar with the agreement said the share declined over time.

Ten-year retirement agreements such as this are unusual in the corporate world, but financial industry experts say such arrangements make sense for privately held investment partnerships such as Bain. Partnership shares are difficult to divide and, because the company is not publicly traded, it is difficult to offer a retiring founder an immediate payout, experts say.

In Romney’s case, however, the benefits did not stop when the 10 years were up, his disclosure statement and tax return show. As long as any of the Bain investment funds in which Romney invested before 2009 continued to make profits, Romney would continue to share in them. Since these funds often last five to seven years, Romney has continued to profit well beyond the termination of his severance package. Other top executives at Bain have negotiated similar retirement deals, according to a former partner.

Bain executives have said Romney is entitled to continue sharing in the profits, even in retirement, because he built Bain and led it during its most successful period. Romney helped pull together $37 million for the first investment fund, handpicked early partners, personally solicited potential investors, and presided over rigorous debates about firm strategy and acquisition decisions.

Yet some of the retirement benefits no longer flow to Romney individually but to a blind trust he established in the name of his wife, Ann.

In his 2010 tax return, Romney said the Ann Romney blind trust could receive carried-interest profits from a Bain fund based in the Cayman Islands called Bain Capital Partners (AM) X LP. To request the carried-interest tax deduction, which is typically taken by active fund managers, Romney’s attorney filed a tax form telling the IRS that Ann’s trust was “performing services” for the fund.

Tax experts say Romney can legally share in the carried-interest profits and take the deduction if Bain has agreed to the arrangement. Critics of the carried-interest deduction say this example highlights how the tax break can be abused.

“Carried interest was intended to motivate managers going forward,” said Victor Fleischer, an expert in carried interest at the University of Colorado law school. “In cases like the Romneys, it just shows it is really all about fancy tax planning. It’s not motivating managers going forward. Not only is Mitt not providing any future services, Ann never did.”

In recent years, the carried-interest deduction has proved controversial on Capitol Hill. There have been several unsuccessful efforts to eliminate the tax break, which critics say improperly treats profits like capital gains, and tax these earnings as ordinary income at 35 percent.

Some tax experts worry that the arrangements Romney benefits from set a bad precedent for a president. “He looks for every tax angle to a degree that is unbecoming in someone who would be the executive in command of the administrative apparatus that enforces the tax law,” said Lee Sheppard, a tax lawyer and contributing editor for Tax Analysts, a publication for accounting and legal professionals.

Gregory Thomas contributed to this report.