Walmart's online grocery business will thrive and compete well against Amazon, according to Deutsche Bank.

The firm raised its rating to buy from hold for Walmart shares, predicting the retailer will report sales above expectations in its third quarter.

"We believe the company is now in position to accelerate market share gains in grocery while also growing EBIT [earnings before interest and taxes] dollars (ex. Flipkart)," analyst Paul Trussell said Tuesday in a research note entitled "Flexing Its Muscles."

"Given the pace of disruption in the food retail landscape and our framework that the top players will reap the benefits of industry consolidation and increasing adoption of online grocery, we believe WMT is best positioned to continue to take both mind and market share going forward."

Walmart shares closed up 2.5 percent Tuesday.

Trussell raised his price target to $113 from $89 for Walmart shares, representing 19 percent upside to Monday's close.

The analyst noted Walmart had 11 percent of the U.S. online grocery market last year. He predicts the share will rise to 17 percent versus Amazon's 19 percent in 2025.

"We believe WMT has positive momentum with robust underlying trends in the core business, and an expanding online platform (including both walmart.com and jet.com) that positions the company as a legitimate contender against AMZN in the long-term," he said.

Trussell also increased his Walmart U.S. third-quarter same store sales growth estimate to 3.5 percent from 2.9 percent versus the 2.8 percent Wall Street consensus.

Walmart's stock is down 4 percent this year through Monday versus the S&P 500's 8 percent gain.