Steve Ballmer hasn’t been getting much love recently. On Friday, when he announced that he plans to retire as Microsoft’s C.E.O. at some point within the next year, the firm’s stock had its best day in years, rising seven per cent. Since that Bronx cheer from the markets, the critics have been piling on, describing Ballmer as the tech boss who somehow managed to miss search, social networking, and mobile—the three big trends that have revolutionized the industry in the past decade and a half.

Tim Bajarin, the president of the research firm Creative Strategies, told Bloomberg News: ”He stayed too long at Microsoft with a position focused on PCs, and didn’t really anticipate the dramatic impact of mobile computing.” MacDaily News called his thirteen years as C.E.O. “the luckiest dorm assignment in the history of the universe.” (Ballmer met Bill Gates, who eventually appointed him as his successor, when they were both students at Harvard.) My colleague Nick Thompson noted that Ballmer’s “reign has done more to defang Microsoft than the Justice Department could ever have hoped to do.” Even Paul Krugman took a day off from bashing the Republicans to weigh in, comparing Microsoft under Ballmer to a medieval dynasty that was too corrupt and complacent to fight off the barbarians.

I suspect that Krugman hasn’t seen Ballmer in action. The man’s a walking heart attack—the one thing he isn’t is complacent. For the past thirteen years, he has been engaged in a daily battle to fight off the Silicon Valley hordes. Ultimately, he didn’t succeed, but he didn’t really lose either. In 2000, the year he replaced Gates as C.E.O.—the Microsoft founder stayed on as chairman until 2006—the firm made a net profit of $5.8 billion, on revenues of $23 billion. In the twelve months that ended in June of this year, it netted $21.9 billion, on revenues of $77.9 billion. Yes, that’s right: under Ballmer, Microsoft more than tripled its revenues and profits.

In most industries, such a financial record would be considered a great success. Setting aside Apple, which I’ll come to in a bit, the only U.S. companies that regularly generate more profits than Microsoft does are the giant oil corporations (ExxonMobil and Chevron, for example) and the too-big-to-fail banks (JPMorgan Chase, Wells Fargo, and the like.) In Silicon Valley, however, the ultimate barometer of success isn’t making profits: it is being in the vanguard of the latest cool technology. By this metric, the Ballmer bashers argue, he doesn’t measure up to folks like Steve Jobs, Larry Page, Sergey Brin, Mark Zuckerberg, and David Karp.

That’s true, but it’s an unfair comparison. Ballmer isn’t a technologist; he’s a businessman who started out at Procter & Gamble. To describe him as a failure is to misunderstand how the technology industry works these days. At once oligopolistic and highly competitive, it is perhaps best described as an ongoing lottery in which the prizes, bestowed at irregular intervals, are temporary monopolies in a given market, such as P.C. operating systems, search, or tablets.

In this setup, there are two very different types of players, each with very different incentives: those entering the lotteries, and those who have already won one. The job of the lottery entrants, such as Zuckerberg when he launched Facebook, in 2004, and Karp when he launched Tumblr, in 2007, is to come up with innovative and exciting products that the judges—investors and the public—are likely to award first prize. (The contest is a lottery because there are often many competing products, with little to distinguish them save that one has first-mover advantage.) The job of the lottery winners is to make the most of their monopoly franchise, building it out and making it last as long as possible.

Most of Ballmer’s critics ignore this crucial distinction. They attack him for being a poor lottery entrant, but he wasn’t hired to play that game—he was chosen to run a company that had already won the prize. And, as a monopolist, he was pretty effective. Under the leadership of Gates and Ballmer, Microsoft dominated the computer business for more than two decades. In such a fast-moving industry, that’s a very long time. Only I.B.M. has had a comparable reign.

The lottery in P.C. operating systems was held way back in the early nineteen-eighties, and Microsoft won it—courtesy of a monumental blunder by Big Blue, which chose to license Microsoft’s DOS instead of buying it outright. Under Gates’s leadership, Microsoft then cemented its lock on operating systems, replacing DOS with many iterations of Windows, and eventually, through Office, extended its grip to productivity software. But, by the time that Ballmer replaced Gates, Microsoft’s grip on the industry was already under threat, due to the rise of the Internet and the government antitrust case that accompanied it.

In running the sprawling firm for thirteen years, Ballmer never lost sight of the fact that shoring up Windows and Office was his first priority. He saw off the threat from Linux and other open-source operating systems, which were much cheaper than Windows, and arguably better, too. He licensed Office to Apple to make sure that the company’s resurgence didn’t threaten Microsoft’s grip on the business market. And when other rivals started to offer cheap software that could be downloaded from or used on the Web, like Google Docs, he managed to persuade most of Microsoft’s customers to pay hundreds of dollars a year to stay with Office. Microsoft’s two core businesses continued to thrive. In the past twelve months, Windows and Office generated more than twenty seven billion dollars between them in operating income.

Some critics point to the fact that Microsoft’s share price has languished, but that’s based upon another misunderstanding. When a tech business like Microsoft or Google or Apple establishes a temporary monopoly, its stock price shoots up in anticipation of future profits. If the firm doesn’t fulfill its promise, its stock price collapses. If it does, it spends many years growing into its valuation, which is what Microsoft has done. Since the bursting of the tech bubble, in 2000, the company’s stock price hasn’t gone anywhere. But since 1986, when it went public, the stock is up more than five-hundredfold.

What about extending the firm’s monopoly power to adjacent markets—the other job of a monopolist? Ballmer can hardly be blamed for the fact that the federal government quite rightly stymied its efforts to monopolize the market for Web browsers. If the antitrust case hadn’t happened, Microsoft might well have come to dominate the search market, precluding the rise of Google. Once Judge Thomas Penfield Jackson torpedoed Microsoft’s efforts to establish itself as the gatekeeper to the Web, it opened up all sorts of other possibilities that Microsoft couldn’t control, including the establishment of rival technology platforms based on search and social networking. (Matt Yglesias has more on this.)

Forced to compete on a more level—and less profitable—playing field, Ballmer still did a defensible job of creating new businesses. Xbox is the obvious one. Largely unnoticed by the public, Microsoft has also built a big and profitable business in marketing technology and services to corporations, especially via powerful cloud servers. During the second quarter of this year, its “Server and Tools” division generated more than eight billion dollars in operating income, almost as much as the Windows division. And that’s a business that was created almost entirely on Ballmer’s watch.