On a Thursday evening three Junes ago, Dejan Karabasevic desperately needed to contact his former wife. Karabasevic, a top engineer in American Superconductor Corp.’s offices in Klagenfurt, Austria, had been summoned to work, then confronted by police, who suspected him of selling his company’s proprietary software to a Chinese wind turbine maker.

The questioning lasted past midnight. When he finally reached his former wife, he instructed her to delete all the e-mails in his Google account. But authorities stopped her before she could.

The e-mails proved the basis for Karabasevic’s subsequent arrest and conviction in an Austrian court on charges of revealing trade secrets. His case marked what would be the opening round of a two-year fight by the Devens-based technology firm known as AMSC to defend its intellectual property rights — even as it lost millions of dollars and laid off hundreds of workers as the result of the software theft.

It would also open a window on the sometimes tawdry world of economic espionage between companies battling for preeminence in emerging energy markets.

The saga — pieced together with court records, financial filings, and interviews — took private and federal investigators from a wind farm in China to corporate offices in Austria and Middleton, Wis., and ultimately back to Massachusetts. Here, less than 40 miles from the headquarters of AMSC, FBI agents found a key piece of evidence that helped persuade a federal grand jury recently to indict Sinovel Wind Group Co. of Beijing, two of its employees, and Karabasevic on charges of conspiracy, wire fraud, and the theft of trade secrets.

The giveaway: a bit of pirated software found in a Sinovel-made turbine in Charlestown. Authorities believe the Chinese manufacturer stole the software from the Devens company, installed it in Sinovel turbines, and then sold the illegally equipped turbines in the United States at a profit.

A Sinovel lawyer, Matthew Jacobs, declined to comment.

The indictment underscores one of the most contentious issues in Sino-American relations, the protection of the intellectual property of companies doing business in China. How this criminal case — as well as four suits that AMSC filed against Sinovel in Chinese courts — plays out could influence relations between the two countries for years to come.

“It’s important because a lot of people lost their jobs all over the country,” said Timothy O’Shea, an assistant US attorney in the Western District of Wisconsin, where the indictment was filed. “It’s important to protect intellectual property so that people have an incentive to innovate and invest.”

Sinovel was founded less than a decade ago, initially financed by a Chinese government that has aggressively pursued alternative energy to satisfy the nation’s hunger for power and establish China’s leadership in an emerging technology. As with many businesses in strategic industries targeted by Chinese planners, Sinovel sought the know-how of a foreign partner.

Sinovel built the wind turbines, and AMSC supplied the software to control their operations. By 2009, Sinovel had become one of world’s leading wind turbine makers, and the partnership with AMSC was so successful that President Obama touted it as a model for other US companies to follow.

AMSC’s revenues soared, and by 2011 Sinovel accounted for nearly 80 percent of its sales. AMSC opened offices around the world, adding jobs and expanding its global workforce. The company’s stock price climbed, too, during this period, more than doubling to about $25 a share.

It appeared to be the perfect partnership, a true collaboration between the Massachusetts company and the Chinese manufacturer, and a boon to alternative energy. But Sinovel, court records show, would soon decide that it was time to cut AMSC out of the deal. Sometime around February 2011, it began wooing Karabasevic, a Serbian national working in AMSC’s Austrian office, ultimately promising him a six-year, $1.7 million contract with Sinovel and “all the human contact” he could want, “in particular, female co-workers.”

The engineer used his laptop and the Internet to access an AMSC computer in Middleton and download proprietary software code, court documents and other records show. Karabasevic then e-mailed that code and subsequent updates to Sinovel employees.

AMSC got its first hint that something was wrong in March 2011, when Sinovel abruptly refused contracted shipments from the Devens firm, complaining that the software did not meet new power grid requirements in China. With the loss of Sinovel’s business, the company’s stock plunged, and its $1.6 billion market value shrank to just $200 million. More than half of AMSC’s workforce — some 500 employees — was laid off.

By then, Karabasevic was e-mailing and instant messaging regularly with two Sinovel employees, disabling AMSC’s encryptions as the trio worked to adapt the software to turbines in China.

“If you succeed,” Karabasevic wrote in one chat, “Sinovel can separate from AMSC.”

But the scheme began to unravel a month later, when an AMSC field crew doing maintenance on turbines in China noticed blades spinning on a test-version of a Sinovel machine that was supposed to be out of commission. Inside, they found a modified version of software that AMSC had designed.

AMSC hired private investigators, who quickly narrowed the list of suspects to the handful of employees who had access to the stolen software code. By the end of June 2011, they had closed in on Karabasevic, who was arrested by Austrian police.

Ten days before the engineer’s trial in September 2011, AMSC issued a late press release saying that it would sue Sinovel over intellectual property theft. Coincidentally, just hours before AMSC’s announcement, the Massachusetts Water Resources Authority sent out its own release, highlighting its new 1.5 megawatt wind turbine delivered by Sinovel two days earlier.

Lumus Construction of Woburn was hired by the MWRA to assemble the turbine. When the company president, Sumul Shah, received a news alert about AMSC’s charges, he contacted Sinovel, hoping to verify that the machine would run on software made by the Devens company — and not a pirated version.

“Obviously, I was concerned, the MWRA was concerned,” said Shah, recalling that he received assurances from Sinovel. “They said, yep, they’re AMSC components.”

So the $4.7 million project, financed by stimulus money, went forward. Sinovel had one of its employees load the control system software into the 364-foot-tall machine that October, waiting to spin its blades outside the DeLauri Sewer Pump Station in Charlestown.

Five months later, agents with the Federal Bureau of Investigation arrived at the site, search warrant in hand, and climbed the turbine to seize digital evidence of stolen technology. Shah would also lead agents to three more Sinovel turbines in Massachusetts, ordered before AMSC’s accusations became public, and each allegedly running with the pirated software.

“They reimported stolen goods into our home state,” said Daniel P. McGahn, AMSC chief executive. Despite what investigators say is strong evidence against Sinovel, there will be no easy end to AMSC’s drama. The legal case against Sinovel, its employees, and Karabasevic will be difficult to pursue. The United States has no extradition treaty with China, and Karabasevic, after serving a year in Austrian jail, has returned to Serbia, which also has no US extradition treaty.

AMSC has only begun to recover from its losses, and its stock — trading at roughly $2.50 — remains far below its peak during happier days as Sinovel’s partner.But McGahn remains positive that his company will rebound.

“It has been a crazy two years for us,” he said following Sinovel’s indictment. “But we have a criminal indictment, and that opens up a clear path for compensation.”