In the fall of 2009, Governor Deval Patrick joined chief executive David Vieau on a tour of what was perhaps Massachusetts’ hottest company: A123 Systems Inc.

The Waltham battery maker had just raised $380 million in an initial public offering as investors shrugged off the recession and drove the stock 50 percent above the company’s initial pricing. Nearly $400 million in government grants, loans, and tax incentives were already rolling into the company on the promise of a technology that could help transform the nation’s flailing auto industry into a leader in electric cars.

“Guys were tripping over themselves to get in here,” recalled Howard Anderson, an early A123 investor. “I remember hearing the number two guy at GM say, ‘I’ve seen the future and this is it.’”

But that flood of money would sow the seeds of A123’s fall, enticing it to ramp up commercial production too quickly — far faster than the market for electric vehicles would grow. As the economy struggled, gas prices moderated, and a national energy policy failed to gain traction, A123 burned through cash to finance stubbornly high production costs for a market that never really materialized.

Top executives scrambled to develop products, line up new investors, and find more money, bankruptcy records show.

But last week, it became clear that costs would outstrip cash far into the future, and A123 filed for Chapter 11 protection having never turned a profit.

“They were on the knife edge for a while, and they just slipped,” said Andrea James, a senior analyst that tracks A123 for Dougherty & Co. LLC in Minneapolis.

The company “bet its costs would come down and they just didn’t come down quickly enough.”

A123 was born out of a laboratory at the Massachusetts Institute of Technology, where researchers — including eventual company cofounder Yet-Ming Chiang — were developing technology with materials that would allow batteries to produce more power and charge more quickly.

The higher power levels and longer storage life — at least five times those of conventional batteries — meant these advanced batteries could be used in a host of new ways, such as in cars.

Chiang, along with entrepreneur Ric Fulop and high-tech manager Bart Reilly, would later license a thimbleful of this technology from MIT and use it to launch A123 in 2001.

Anderson, now a lecturer at MIT’s Sloan School of Management, recently recalled how Fulop arrived in Anderson’s One Memorial Drive office with an article by Chiang extolling MIT’s battery research. Fulop sold them, Anderson said, with the article and his conviction that A123’s team could commercialize the technology.

“Desh and I and North Bridge [Venture Partners] said yes on the same day,” Anderson said. Soon after, Fulop and his partners were using the copiers and printers at One Memorial Drive to get their business off the ground.

Vieau was brought on a few months later, cherry-picked from American Power Conversion Corp., a Rhode Island firm that makes power supply and protection systems, because of his technical and business background.

He almost immediately demonstrated a knack for finding new markets, customers, and financing whenever A123 needed them most. When the still small start-up was searching for its first customer, Anderson introduced Vieau to directors at Black & Decker.

Vieau persuaded the power tool maker to buy the company’s lithium-ion batteries — even though A123 had no fully developed product.

Following its success in power tools, the company quickly branched out, making batteries for Formula One racing vehicles and New York City buses.

It eventually landed contracts to supply car batteries to Chrysler and SAIC Motor Corp., China’s largest automaker.

A123’s telephones rang constantly with queries about its batteries from big corporations like GM and BMW, Anderson remembered, and economic development officials in Michigan and Massachusetts were chasing the company, turning on the charm, and enticing A123 executives with incentives.

With new technologies as a major component of President Obama’s energy policy, and billions of dollars in stimulus money directed at building an alternative energy industry, it was not long before Vieau and his team found themselves hobnobbing with federal bigwigs like Energy Secretary Steven Chu.

Nearly $250 million in US taxpayer money was soon on its way to help A123 build 600,000 square feet of factory space in Romulus and Livonia, Mich., to manufacture batteries for Detroit’s auto industry. When A123’s Livonia plant opened in 2010, Chu and Jennifer Granholm, then Michigan’s governor, were on the guest list.

Vieau led reporters, customers, and others on tours, pointing out the gleaming silver and white machinery whirring under the watchful guidance of new workers — some of whom had lost jobs in the recession.

The company continued to expand, providing batteries for hybrid BMWs, SAIC’s Roewe sedans, and the Karma, made by Fisker Automotive in California. Massive A123 power storage systems, meanwhile, were shipped to utility customers in Europe and South America.

At its peak, A123 employed several thousand employees in Michigan, Massachusetts, China, and Germany.

But even as it grew, revenues failed to keep up with costs. The Waltham firm was bleeding cash, losing $86.59 million in 2009, $152.94 million in 2010, and $257.76 million in 2011, court records show.

The situation became worse. At the end of last year, Fisker cut its production of electric vehicles and slashed battery orders, forcing A123 to cut its 2011 revenue expectations by $45 million. Soon after, A123 discovered a defect in batteries that led to a pricey recall. The cost: $67 million.

Meanwhile, a national energy policy that might have helped companies like A123 through rough spots until market demand reached critical mass never materialized. Popular support for clean technologies waned as the economic downturn dragged on and record high fuel prices fell.

The industry’s reputation also took repeated hits in 2011 as government-funded firms like California solar panel maker Solyndra LLC and Tyngsborough energy storage firm Beacon Power Corp. filed for bankruptcy.

It all left A123 nearly desperate for an infusion of cash.

In February and March, the company came close to an agreement with a potential investor, but the deal fell through. Around the same time, A123 hired the investment banking firm Lazard Freres & Co. LLC to reach out to 74 potential partners. Only one-third of those followed up, and less than a handful offered a small amount financial help.

Vieau continued to try to save the company, courting new customers, improving technology, and seeking new investors. But A123 appeared to be in a death spiral. Its stock had fallen well below $1, spooking investors who spent the last few months dumping shares.

Most notably, longtime investor North Bridge — which today employs Fulop and A123 board member Jeffrey McCarthy — sold all of its A123 stock by Sept. 10. Neither Fulop or McCarthy, who resigned from A123’s board earlier this month, responded to repeated requests for comment.

But Vieau kept looking for a savior. Rival US battery maker Johnson Controls Inc. of Milwaukee, expressed interest in investing, a courtroom transcript shows, but it was not strong enough for them to move forward. Vieau and A123 then made a $465 million deal with a Chinese firm, Wanxiang Group, an auto parts conglomerate.

But that proposal, which would have given Wanxiang an 80 percent stake in A123, sparked criticism from Republican congressional members and others worried about a Chinese company ending up with technology funded by US taxpayer money.

It appeared unlikely that A123 could get government approval of the deal before it ran out of cash.

And that’s how Vieau and a cadre of lawyers found themselves on the fifth floor of a federal courtroom in Wilmington, Del., at three minutes after 11 a.m. Thursday, as Wanxiang and Johnson Controls began jockeying to buy the bankrupt company.

Analysts said a bidding war could ensue, an indication of the value of A123’s technology and its potential for helping create a future with electric cars and large-scale power storage.

“It’s nice that the debtors [have] become the popular girl at the dance,” said Judge Kevin Carey at a recent bankruptcy hearing, “and it has at least two suitors, maybe more.”

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.