Wells Fargo & Co. agreed to pay roughly $145 million to settle a lawsuit over government allegations that the bank’s retirement plan overpaid for company stock, the U.S. Labor Department said Monday.

Under the settlement agreement, the third-largest U.S. bank by assets will pay $131.8 million to eligible current and former 401(k) plan participants, as well as a nearly $13.2 million penalty to the Labor Department. The settlement puts to rest a yearslong Labor Department investigation into Wells Fargo’s retirement plans, though the bank still faces a number of separate legal disputes.

The Labor Department investigation found that Wells Fargo and its trustee GreatBanc Trust Co. allegedly paid between $1,033 and $1,090 per share for preferred stock, but converted it to a set value of $1,000 when it was allocated to participants through its 401(k) plan, the department said.

Wells Fargo and GreatBanc Trust also allegedly used the dividends from the preferred shares to make contributions to the 401(k) plan, repaying stock purchase loans with them. The transaction “was designed to cause the 401(k) plan to pay more for each share of stock than plan participants would ever receive,” according to the Labor Department.

Labor Secretary Marty Walsh said those responsible for the 401(k) plan “betrayed the trust of the plan’s current and future retirees.”

“Today’s settlement shows the Department of Labor will act when we find retirement assets are misused and benefit plans suffer,” he said in a statement.

Wells Fargo did not admit or deny those allegations as part of the settlement. In a statement, the bank strongly disagrees with the DOL allegations and believes it followed applicable laws in the transactions, which it said it has not conducted since 2018.

”All 401(k) Plan participants received all matching and profit-sharing contributions due to them,” the company statement said. “An independent third-party approved the transactions on behalf of the 401(k) Plan and confirmed that the 401(k) Plan did not pay more than fair market value for the Company stock at issue.”

Under the Employee Retirement Income Security Act of 1974, retirement plans cannot pay any more than market value when they purchase company stock.

Wells Fargo is grappling with a series of lawsuits and penalties that could weigh on the bank even as higher interest rates boost revenue. Its estimated potential legal costs rose to $3.2 billion in the second quarter, compared with $2.8 billion from the previous quarter and $2.4 billion at the end of 2020, according to Elliott Stein, a senior litigation analyst at Bloomberg Intelligence.

The mounting costs “underscore its lingering legal issues despite the recent resolution of some matters,” Stein said.

In Wells Fargo’s second-quarter earnings call, chief financial officer Mike Santomassimo said “outstanding litigation, regulatory matters, and customer remediations, and the related expenses could be significant and hard to predict.”