Target Corp on Wednesday reported higher-than-expected quarterly profit and comparable-store sales after four straight quarters of declines as more customers visited its stores and website.

Target shares jumped 5.1 percent to $57.11 in premarket trading after the retailer said second-quarter traffic increased more than 2 percent.

Like other retailers, Target has been struggling to boost traffic amid changing consumer habits and competition from e-commerce giant Amazon.com Inc. Target shares are down 25 percent since the start of the year, widely lagging larger rival Wal-Mart, whose stock is up 17 percent.

In its latest turnaround bid, Target vowed this year to double the number of small-format stores, invest heavily in e-commerce, aggressively promote its products and keep grocery prices low to compete with Wal-Mart, Amazon and Kroger Co.

Moody's retail analyst Charlie O’Shea said since Target's share repurchases for the quarter "slowed to a trickle," it will give the retailer the cash to execute its transition plan.

The scope of Target's transition plan made it difficult to compare the retailer's performance to prior quarters, he added.

Sales at stores open more than 12 months rose 1.3 percent, above the 0.7 percent growth expected by analysts polled by research firm Consensus Metrix.

Excluding items, Target earned $1.23 per share in the quarter ended July 29, beating the average analyst estimate of $1.19, according to Thomson Reuters I/B/E/S.

Sales rose 1.6 percent to $16.43 billion, above the average analyst estimate of $16.30 billion.

Reuters (Reporting by Sruthi Ramakrishnan in Bengaluru and Richa Naidu in Chicago; Editing by Martina D'Couto and Jeffrey Benko)