Gap on Thursday surpassed Wall Street expectations for the second quarter, as a surprise early announcement of its results showed shoppers turned to its Old Navy and namesake brands to snap up trendy and fashionable clothing.

Shares of Gap closed up nearly 2% at $22.8. The stock was halted during the day following a Bloomberg News report that said the apparel retailer's earnings press release and presentation appeared on its website in the morning, hours earlier than scheduled.

A Gap spokesperson told Reuters that the company's results were briefly and accidentally posted on its website due to an administrative error. It was originally scheduled to release the numbers after the bell.

The Banana Republic owner is in the midst of a brand turnaround under CEO Richard Dickson and has been ramping up its stores with fresher and more chic styles to bring back lost customers.

Dickson on a post-earnings call said Gap's consumer base has broadened and the company is seeing more sell-throughs at full-price, resulting in less discounting.

People, who are otherwise saving dollars and curbing spending on big-ticket items, are more than willing to go all out and spend on in-trend footwear and clothing such as those from Abercrombie & Fitch, Roger Federer-backed On and Deckers Outdoor's Hoka.

"(Gap) is being managed better than it was ... it is not like all four brands are really completely healthy, but they are trending in the right direction under the new management," Morningstar analyst David Swartz said.

Comparable sales at Old Navy rose 5% during the quarter, while the Gap brand posted 3% growth. Banana Republic sales, however, were flat as the brand continues to focus on fixing the fundamentals and improve its pricing and assortment architecture.

Gap's second-quarter net sales rose 5% to $3.72 billion, beating LSEG estimates of $3.63 billion.

It earned 54 cents per share, also topping analysts' average estimate of 40 cents.

The apparel retailer reaffirmed its annual net sales forecast and expects gross margin to expand by about 200 basis points versus its prior forecast of at least a 150-basis-point increase.

(Reporting by Ananya Mariam Rajesh and Savyata Mishra in Bengaluru, Additional reporting by Juveria Tabassum; Editing by Shilpi Majumdar and Maju Samuel)