Mary Becker, the mayor of Juneau, Alaska, got a phone call early Friday morning with news she later called "devastating." The lone Walmart Supercenter in Juneau—opened with fanfare and celebration in 2007 as the first Supercenter in Alaska—would be closed permanently, in just 21 days.

"It was a shock," she said. "It’s a very upsetting bit of news for Juneau."

Juneau is an unusual city in the U.S. It has no roads in or out. Although it’s a state capital, Juneau’s connection to the outside world is via boat or plane. In a community like that, Walmart plays a special role, providing access to a range of everyday items that residents would either have to order by mail, or travel long distances to buy.

And the next closet Walmart is a 300-mile flight to the south, in Ketchikan, Alaska.

Walmart’s decision on January 15th to close 269 stores worldwide, 154 of them in the U.S., is bigger news than a routine announcement of modest cuts by a global mega-business. The retail behemoth has never before done a sweeping closure of U.S. stores that weren’t successful. In fact, in Walmart’s 52-year history in the US, as far as can be determined, the company has only closed one store (in Connecticut) because it wasn’t doing enough business. Walmart routinely closes existing stores—but only in order to relocate them a half-mile away, typically at double the size of the abandoned store.

It's a stunning development for a company that until very recently seemed to be not just the dominant force in retail, but among the most dominant forces in all of business. Walmart not only sits in the #1 spot on the Fortune 500 largest companies, its sales put it $100 billion ahead of #2 (ExxonMobil). Walmart has been in first place every year for the last 15 years except four, and it will be #1 again this year.

But suddenly, Walmart not only doesn’t seem dominant, it seems positively vulnerable. That very vulnerability gives the announcement of hundreds of store closings real significance. It’s a sign of two things.

It may seem paradoxical, but this is what it looks like when a giant like Walmart gets its mojo back. The clear-eyed, uncompromising, even unsentimental decision-making necessary to close stores when you’ve never closed them before is a sign of a new discipline and a new rigor inside Walmart. It’s a sign that Walmart’s young CEO, Doug McMillon, for all his low-key charm and personability, is willing to say: We’ve made mistakes. This is what mistakes look like. We’re going to fix them—even if that’s embarrassing and painful.

Second, the store closings may be a sign that it’s too late. Walmart has all the resources it could possibly need to adapt to a changing world. But sometimes, resources aren’t enough. Sometimes the world changes faster than the giants can, even when they know exactly how the world is changing and what they have to do to keep up.

Walmart isn’t about to crumble. The company is often compared in the same breath to Target, Costco, and Amazon. But Walmart does more business by February 25 than Target does all year. Walmart is twice as big as Costco and Amazon combined.

A Walmart employee hangs signs on the front entrance telling customers that this store location will be closing in two days.Photo: Kathryn Scott Osler/The Denver Post via Getty Images

But here’s what Walmart isn’t doing that it used to do so well: It isn’t innovating. It doesn’t lead the pack.

There are many places where Walmart has missed keeping up with its retail competitors. But consider just one. If you shop at Walmart regularly for the items it specializes in—everyday supplies like diapers, paper towels, toothpaste, laundry detergent, deodorant, and corn flakes—well then Walmart has you on a kind of monthly payment plan. You go to Walmart, you fill your cart with vital supplies for your family, and as you check out, you know that almost everything in that cart will be gone in a week or two. And you’ll have to go back to Walmart and resupply.

Walmart has all that data. Walmart knows what people buy, it knows the pacing, it knows how often you need Tide versus Pampers versus Windex. And Walmart knows something else, too: It knows that no one, in 2016, relishes the effort of stocking up on all that stuff. For modern families, that’s not shopping—it’s not like wandering into an Apple store or even a Whole Foods. Those kinds of purchases are simply logistics, family-scale.

So why hasn’t Walmart figured out how to automate that process for us—how to make it frictionless, thoughtless, even brilliant? Way back in 1961, when Walmart was born, that was a core element of Sam Walton’s insight: Put everything in one store and assure your customers that the merchandise was as cheap or cheaper than anywhere else. Make shopping easy.

Supercenters don’t look easy these days. They look like a trudge. Amazon—which isn’t yet most Americans go-to source for Tide or Pampers—is running circles around Walmart when it come to innovating.

That’s why Walmart suddenly looks so vulnerable, even though it remains a behemoth—even though, in fact, it remains the behemoth.

For four decades, Walmart was so threatening—and in many ways so thrilling—because it was setting the pace. Walmart acted, and everyone else reacted. Walmart was setting the tempo of the retail ecosystem—you could co-exist with Walmart, but you had to do it within the environment they created.

Today, Walmart seems beatable because it is Walmart that is reacting. Walmart isn’t the retail innovator, it’s scrambling to react to everyone else’s innovations. Website to store? We got that! Home delivery? We got that! Order groceries online for parking-lot pickup? Just pull in, we’ll tuck the groceries in your car and close the trunk for you.

It’s hard to conquer the world if you’re just trying to keep up.

In 1979, Walmart first did $1 billion in sales. That year, Sears was at $30 billion in sales. If Sears had been paying attention to what Sam Walton was doing, it could have crushed Walmart.

Walmart launched its retail website in 1999. That year, Amazon.com was five years old. Amazon’s sales were $1.6 billion. Walmart’s: $138 billion.

In 2016, walmart.com is expected to do $13 billion in sales—not even 3% of Walmart’s business. Amazon will do $100 billion. In the last year, Amazon has added more business than walmart.com has after 17 years.

Not, mind you, that Walmart is conceding the field. It now has 2,400 employees in Silicon Valley working to improve walmart.com. Walmart’s discipline is unrelenting. The company makes more profit every 42 days than Amazon has made in the last 18 years.

The store closings will ultimately save money. But Walmart is spending money to try to both improve its performance and remain competitive. That’s the idea behind the company raising its minimum pay— to $9 an hour last year, and to $10 an hour for all full-time employees on February 20. In fact, Walmart announced yesterday that almost every full-time hourly U.S. employee will receive a raise on February 20—Walmart is giving annual raises to everyone on February 20, without waiting for the anniversary dates when raises normally take effect.

The raises are Walmart’s effort to woo employees as the unemployment rate drops, and also to hang on to current employees. The company has historically had a brutal 50% turnover rate—losing more than 10,000 U.S. employees every week. And the raises are not cheap. Walmart is spending $2.7 billion on increased pay and training in 2015 and 2016—$25 million a week—and the raises could cut profits this year between 6% and 12%. Company CEO McMillon sees them as an investment in better staff, and a better experience for customers in stores.

No one should hope for a hobbled, stumbling Walmart. The company is now an institution across the American landscape, part of the very infrastructure of how the country works.

And it has learned a lot in the last 10 years about how to relate to the places it does business. On Friday, before the company made public the list of store locations it was closing, it called elected officials in every community to let them know in advance and to answer questions—a courtesy impossible to imagine from Walmart of 2006.

One person who got a call was Bill Cole, the president of the West Virginia state senate. Walmart has 44 stores in West Virginia, and it is closing one—in the town of Kimball, in McDowell County, where it is the only major store within an hour’s drive. A Walmart official called McDowell County’s administrator to warn her of the closing on Friday morning, and he also called Sen. Cole.

"McDowell County is the poorest county in West Virginia," says Cole. "It’s the eighth-poorest county in the nation, I believe. I think they called because they were trying to get ahead of the story. It wasn’t going to be taken as good news."

Cole, in turn, called Walmart’s lobbyist in Charleston, West Virginia’s capital, "to try to go to bat for keeping that one store open," he said. "She said it was really a global strategy decision that came down from on high."

In a terrible irony, the Kimball Walmart has been one of the major suppliers to a critical food bank in McDowell County, a place hit hard by the downturn in the coal business.

"When the Walmart there closes, we’re not only losing the ability for people who can afford to shop there to get what they need," says Cole. "We’re losing the ability to provide for people who can’t even afford to shop at Walmart."

It turns out that perhaps the only thing worse than having Walmart come to town is having Walmart leave town.

Never miss a story.

Sign up for the Fast Company newsletter and get the best stories delivered to your inbox daily.