Wal-Mart Stores Inc. on Thursday reported a higher-than-expected 2.4 percent June rise in sales at its U.S. stores open at least a year, and the world's largest retailer said its second-quarter earnings forecast is attainable.

But the retailer also said the environment remains challenging, and it forecast July sales at stores open at least a year would rise only between 1 and 2 percent.

Consumers continue to be challenged financially, with more pressure on discretionary spending, said Eduardo Castro-Wright, Wal-Mart Stores U.S. president and chief executive officer, in a statement.

He said gasoline prices are shoppers' chief concern, according to its latest survey.

Wal-Mart's 2.4 percent rise in same-store sales, excluding fuel, exceeded analysts' average expectation of a gain of 0.9 percent, according to a Reuters survey. The company had also forecast sales would be flat to up 2 percent.

Before the market opening, Wal-Mart shares were up 1.7 percent to $48.50 in electronic composite trading.

Including fuel, June U.S. same-store sales rose 2.5 percent.

The retailer said net sales in the month increased 9.4 percent to $35.81 billion.

The company said its second-quarter earnings per share forecast of 75 cents to 79 cents from continuing operations is attainable. Analysts, on average, are expecting it to earn 77 cents per share, according to Reuters Estimates.

(Reporting by Nicole Maestri)