Cyberattacks linked to Iranian hackers have targeted thousands of people at more than 200 companies over the past two years, Microsoft Corp. said, part of a wave of computer intrusions from the country that researchers say has hit businesses and government entities around the globe.

The campaign, the scope of which hadn’t previously been reported, stole corporate secrets and wiped data from computers. It caused damages estimated at hundreds of millions of dollars in lost productivity and affected oil-and-gas companies, heavy-machinery...