T-Mobile, the nation's fourth-largest wireless carrier, is agreeing to pay at least $90 million as part of a settlement with federal and state officials over third-party fees that it added to consumers' bills without their knowledge or consent.

The hidden fees showed up on billing statements as a "premium" text messaging service when in fact, the complaint alleged, the messages contained spammy horoscope information or celebrity gossip that customers never signed up for. The tactic, known as mobile cramming, benefited T-Mobile when the company took a 40 percent cut of every third-party charge.

"Mobile cramming is an issue that has affected millions of American consumers," said Federal Trade Commission Chairwoman Edith Ramirez, "and I’m pleased that this settlement will put money back in the hands of affected T-Mobile customers."

The settlement involves the FTC, the Federal Communications Commission, and the attorneys general of all 50 states and the District of Columbia. Under the agreement, T-Mobile will pay back $90 million to consumers, or more if the demand for refunds exceeds that amount. In addition, T-Mobile will pay a $4.5 million fine to the FCC and $18 million to the states. T-Mobile will also agree not to engage in future mobile cramming, according to the settlement.

"Today's settlement is a win for consumers who have been victimized by cramming," said FCC Chairman Tom Wheeler, who said T-Mobile's practice was "unacceptable."

The settlement comes days after another federal agency, the Consumer Financial Protection Bureau, announced it was suing the country's third-largest wireless provider, Sprint, for the same tactic.

T-Mobile didn't immediately respond to a request for comment.

Federal data show that only 1 in 20 people ever realize they've been hit by mobile cramming, in part because the fees are buried and relatively small. The FTC has gone after mobile cramming nearly a dozen times.