Billionaire investor Warren Buffett. Bill Pugliano/Getty Images

Warren Buffett's Berkshire Hathaway has sold off $900 million of Walmart stock, choosing instead to invest billions in airlines.

The sale, which leaves Buffett with nearly no shares in Walmart, comes as the US's largest traditional retailer has been rushing to catch up to Amazon and other online competitors.

Amazon's market value is now $356 billion, compared with Walmart's $298 billion. Last year, Buffett acknowledged that traditional brick-and-mortar retailers were struggling in the face of competition from the e-commerce giant.

"It is a big, big force, and it has already disrupted plenty of people, and it will disrupt more," Buffett said at his annual shareholders' meeting in 2016, according to Bloomberg.

Buffett has been paring his stake in Walmart since. He first bought shares in Walmart in 2005.

He said Amazon's competitors, "including us in a few areas, have not figured the way to either participate in it or to counter it."

Since the end of 2014, Walmart shares have fallen 21%, compared with a jump of 119% in Amazon.

Business Insider/Andy Kiersz, data from Yahoo Finance

Former Walmart CEO Mike Duke said in 2012 that his biggest regret as CEO was not investing more in e-commerce to better compete with Amazon.

"I wish we had moved faster. We've proven ourselves to be successful in many areas, and I simply wonder why we didn't move more quickly. This is especially true for e-commerce," Duke said at the time. "Right now we're making tremendous progress, and the business is moving, but we should have moved faster to expand this area."

While Walmart has since invested billions in e-commerce, it holds a tiny share of the market compared with Amazon.

Walmart's online sales were $13.7 billion in 2015, compared with Amazon's $107 billion. Walmart is still ahead in overall sales with $482 billion, more than four times as much as Amazon's revenue.

Buffett's retail instincts have proved correct before — he predicted the downfall of Sears and Kmart in 2005.

"Retailing is like shooting at a moving target," Buffett said at the time. "Turning around a retailer that has been slipping for a long time would be very difficult. Can you think of an example of a retailer that was successfully turned around?"

Sears has since closed hundreds of stores and seems to be headed for bankruptcy. Macy's and JCPenney are also closing hundreds of stores across the US.

While Walmart's footprint hasn't shrunk, many analysts say the US is still over-stored.

The US has 23.5 square feet of retail space per person, compared with 16.4 in Canada and 11.1 in Australia — the next two countries with the highest retail space per capita, according to a Morningstar report from October.