Lowe's shares surged Wednesday after the home improvement retailer's second-quarter earnings report beat Wall Street forecasts and topped rival Home Depot on same-store sales growth in the U.S.

The report — which exceeded analyst estimates on earnings, revenue and same-store sales — showed that changes made by CEO Marvin Ellison have started to take root and draw more customers.

The company's stock gained more than 10%, closing at $108 a share Wednesday.

"Lowe's has lagged for years. Looking at this report quickly, looking at the last couple of reports, it seems that under the guidance of Marvin, the new CEO, Lowe's is really getting its act together," Oppenheimer analyst Brian Nagel said on CNBC's "Squawk Box." "And frankly, if we're right here and this continues, the stock has a long way to run."

Here's how the company did, compared with what Wall Street was expecting, according to Refinitiv consensus estimates:

Adjusted earnings per share: $2.15, vs. $2.01 estimated

Revenue: $20.99 billion, vs. $20.94 billion estimated

Same store sales: up 2.3%, vs. up 1.9% estimated

"We capitalized on spring demand, strong holiday event execution and growth in paint and our pro business to deliver strong second quarter results," said Ellison, who became CEO just over a year ago. "Despite lumber deflation and difficult weather, we are pleased that we delivered positive comparable sales in all 15 geographic regions of the U.S."

Deflation in the price of lumber also hurt Home Depot, which reported better-than-expected earnings Tuesday but missed on sales and cut its outlook for the year. Home Depot also said tariffs on Chinese goods were projected to impact the company's sales.

Lowe's earnings guidance for the fiscal year ending Jan. 31 remained the same: adjusted earnings per share ranging from $5.45 to $5.65.

Lowe's net income rose 10% to $1.68 billion, or $2.14 a share, during the fiscal quarter ended Aug. 2, compared with $1.52 billion, or $1.86 a share a year earlier. Excluding one-time items, it earned $2.15 a share, surpassing analyst expectations by 14 cents.

Revenue during the second quarter rose slightly to $20.99 billion, exceeding expectations of $20.94 billion.

Sales at Lowe's stores open at least 12 months improved 2.3%, beating the expected 1.9% increase. The company also reported U.S. same-store sales were up 3.2%, slightly higher than Home Depot's 3.1% in the U.S.

Earlier this month, Lowe's announced plans to lay off thousands of workers, and last year said it is shuttering stores to reduce costs. Ellison's initiatives also include the creation of a technology hub in Charlotte, North Carolina, that will house as many as 2,000 workers.

The company said it repurchased $1.96 billion of stock and paid $382 million in dividends in the second quarter.

Shares of Lowe's have risen almost 6% since January, valuing the company at around $76.62 billion.