NEW YORK — Credit card company American Express said its second-quarter profit fell 33 percent, largely because it had a significant one-time gain last year tied to the winding down of its business relationship with Costco.

The New York-based company earned $1.31 billion in the three-month period ending June 30, or $1.47 a share, compared with a profit of $1.98 billion, or $2.10 a share, a year earlier. The results beat the expectations of analysts who, according to FactSet, were looking for AmEx to earn $1.43 a share.

American Express’ results for the quarter were distorted by AmEx’s one-time gain of $1.1 billion last year from selling the Costco credit card portfolio to Citigroup. The company’s expenses rose sharply compared with a year ago, because of the tax treatment and restructuring charges AmEx had to book when the Citi deal closed.

AmEx’s U.S. consumer card business reported a profit of $440 million, down 59 percent from a year ago, again because of the sale of the Costco portfolio.

Looking past the effect of the end of the Costco relationship, AmEx is showing signs of recovering from losing a significant part of its business. This is also the last quarter that will contain all the adjustments that AmEx has had to make since the transfer of the Costco portfolio.

“We’ve been focused on emerging from the transition with a stronger, more diversified mix of businesses,” AmEx Chairman and CEO Kenneth Chenault said in a prepared statement.

The number of cards AmEx has issued grew both in the U.S. and globally. The average amount spent on an AmEx card grew, and more customers were keeping a revolving balance on their cards.

AmEx makes most of its money by taking a small percentage of each transaction that runs on its network, so the more money that is spent on its cards, the more revenue AmEx earns. Historically, most AmEx cards have needed to be paid in full at the end of each billing cycle, but the company recently has been encouraging customers to keep a balance, even among its traditional green, Gold and Platinum Card members. This allows AmEx to earn interest on those balances, along with the fees it collects from merchants to accept the cards.

“It gives us a unique opportunity – people we know really well, our existing customers – and try to get more of their borrowing behavior,” Jeffrey Campbell, the company’s chief financial officer, said during a call with analysts.

But allowing more customers to carry a balance comes with the risk that customers may default or get in over their heads. AmEx had to write off more loans this quarter.

In total, AmEx had revenue of $8.31 billion in the period, also topping Wall Street forecasts. The company also said it expects full-year earnings to be $5.60 to $5.80 per share.

AmEx shares fell 1.4 percent in after-market trading to $84.75.