PetSmart Inc. agreed to be bought by a group led by BC Partners for about $8.3 billion in the largest leveraged deal for a U.S. company this year.

The group will pay $83 a share, or about 39 percent more than the company’s price on July 2, before activist investor Jana Partners began pushing for the sale, according to a statement today. Including debt, the total value of the deal is about $8.7 billion, the statement shows.

BC Partners beat other bidders including Leon Black’s Apollo Global Management and KKR & Co. to close the deal after a weekslong auction that came down to negotiations over the weekend, people with knowledge of the matter said. BC Partners struck a deal on Sunday, after making a final offer a day earlier that topped other bids, the people said, asking not to be identified discussing private information.

“It was a very competitive auction,” Raymond Svider, a managing partner at BC Partners, said in a telephone interview. “The company should never have been put in play. Growth slowed and the market overreacted. We feel fortunate.”

A spokesman for Apollo declined to comment, as did a representative for Jana and a spokeswoman for KKR. In addition to BC Partners, the consortium includes Caisse de Dépôt et Placement du Québec and StepStone.

The sale is a victory for Jana and Longview Asset Management, which also urged the retailer to sell itself as its business waned. Same-store sales at the pet-supply company were flat last quarter after falling in the previous three months for the first time in at least a decade, as competition from Amazon.com Inc. and other retailers intensified.

Until Jana, the $10 billion hedge fund run by Barry Rosenstein, began its campaign on July 3, PetSmart’s shares had tumbled 18 percent in 2014. Longview, which controls about 9 percent of PetSmart, said later that month it also backed a sale. Longview supports the sale to BC Partners, according to the statement.

Shares of Phoenix-based PetSmart have now gained 6.8 percent this year, closing at $77.67 on Dec. 12, compared with an 8.3 percent gain in the Standard & Poor’s 500 Index.

Including debt, the buyout group is paying about 9.3 times PetSmart’s earnings before interest, taxes, depreciation, and amortization in the 12 months through Nov. 2, data compiled by Bloomberg show. That compares with a median of 8.9 times historic Ebitda paid in 24 buyouts of U.S. consumer companies over $1 billion in the last five years.

The private-equity deal tops Blackstone Group LP’s $5.4 billion purchase of industrial-products maker Gates Global LLC in July, data compiled by Bloomberg show. Buyout firms have held off on making purchases this year, as valuations climb with stock benchmarks that have reached records.

PetSmart made a good buyout candidate because of its high free-cash-flow yield -- a measure of how much cash from operations the business generates relative to its share price, analysts have said. Petco Animal Supplies Inc., a PetSmart competitor, was acquired by private-equity investors led by Leonard Green & Partners in 2006, and buyout firms also may be interested in PetSmart thanks in part to an attractive financing market, Jana said in July.