After studying the issue for nearly two years, St. Jude Medical alerted patients and doctors Tuesday that almost 350,000 of its implanted defibrillators have batteries that could fail with little warning.

The Little Canada-based maker of advanced heart devices said the rare but serious problem with the lithium batteries is already linked to two deaths.

Implantable defibrillators comprise St. Jude’s largest-selling product category, with $1.5 billion in global sales last year. The devices monitor the heart beat to prevent sudden cardiac arrest and heart beats that are too slow.

An implantable defibrillator can shock the heart back into rhythm if it stops beating normally, which means it needs a powerful battery. But doctors on Tuesday said the patients most affected by the alert are those who depend on their defibrillator to “pace” the heart to a normal rhythm.

The batteries tend to fail between three and four years after implant, doctors said.

St. Jude’s alert said patients should get in touch with their doctors if they think they have an affected device, but early replacement is probably not the best solution for most people. If it is, the company may cover the cost of the device.

The potential problem has been known since late 2014, when St. Jude worked with researchers at Duke University Medical Center in North Carolina who said they discovered a new mode of battery failure called “lithium cluster formation.” The failure rate for the St. Jude defibrillators in the single-hospital study was 0.6 percent, which researcher Dr. Jonathan Piccini said he thought was high.

St. Jude Medical Director Dr. Avi Fischer said Piccini’s 2014 paper, and a second scholarly study last spring, were presented to St. Jude’s medical advisory board of independent experts for analysis. He said a company analysis found a rate of confirmed lithium-cluster failures that was extremely low, causing the advisers to recommend collecting more data and not issuing a public notice.

“We collected more data. We did more product-performance surveillance. When the time was right and we had sufficient data, we convened more meetings, we continued to work with our medical advisory board, we continued to work with regulatory bodies and regulators around the globe. And ultimately we issued the advisory,” Fischer said.

The devices have batteries in which charging may cause lithium to build up and form clusters at the top of the device, which can lead to short-circuits, depending on the location of the deposit.

The devices have built-in vibratory alarms to tell patients if the battery is running low, but physicians said such alerts usually signal that the battery could die within three months. A battery with the lithium-cluster defect may trigger the alarm and then run out of power the next day.

The batteries are manufactured by an outside company that St. Jude declined to disclose Tuesday.

Defibrillators are also programmed to work as pacemakers in some patients, and that function is impacted by the issue. But the battery-failure issue does not affect St. Jude’s stand-alone pacemakers, which are smaller devices that use lower-voltage batteries than defibrillators.

“The patients most at risk are those with a high likelihood of requiring lifesaving shocks, and those who are pacemaker dependent,” the FDA said in a safety communication Tuesday.

The news sent St. Jude Medical stock down 4 percent in early afternoon trading . Shares in Medtronic PLC, another major medical device maker rooted in Minnesota, also fell, and some investment sites speculated that its heart products may be vulnerable to the same battery problem.

A Medtronic spokeswoman said Tuesday that all lithium medical device batteries have the potential to fail in the way that St. Jude disclosed, but Medtronic was still evaluating St. Jude’s findings.

“All high-power [defibrillator] devices from all manufacturers use lithium batteries; however we use a different battery” than St. Jude, Medtronic spokeswoman Kathleen Janasz said via e-mail.

Boston Scientific spokeswoman Trish Backes said that company made changes to its battery design in 2013 after identifying a trend of lithium clusters forming. The company has had no confirmed lithium-cluster battery failures since then.

St. Jude made its announcement Tuesday hours before the FDA published an alert on the device failures. St. Jude’s at-risk defibrillator models include various versions made before May 2015 of its Fortify, Fortify Assura, Quadra Assura, Quadra Assura MP, Unify, Unify Assura, and Unify Quadra devices.

So far, 841 of the 398,740 defibrillators sold worldwide have been confirmed to have premature battery depletion “in association with” lithium cluster formation, including 549 in the U.S. Forty-six of the devices had visible electrical shorting from the clusters.

Roughly 349,850 of the devices remain implanted in patients worldwide today.

At this point, replacing the devices without seeing a malfunction is not recommended, as the risks of complications from replacement surgery like infection are thought to be greater than the risk of premature battery failure. The FDA said most patients will not require a replacement.

But devices should be checked and replaced immediately if a battery warning is detected. The FDA and St. Jude recommended patients enroll in a service called Merlin@home, which can remotely monitor a device battery and send alerts if a problem is detected.

The FDA also said patients with St. Jude defibrillators should seek immediate medical attention if they feel lightheaded or dizzy, or if they lose consciousness, have chest pain or feel severe shortness of breath, all of which may be signs of a depleted battery.

“We recommend that patients and their doctors work together leveraging available resources that include a built-in vibratory notification to the patient, remote monitoring, and in-office visits to ensure they understand the health of their battery. For many health care providers, these are already considered best practice in managing patients with implantable devices,” St. Jude Chief Medical Officer Mark Carlson said.

St. Jude, which has a market capitalization of about $22 billion, is in the process of being acquired by Abbott Laboratories in suburban Chicago.

An Abbott spokesman said St. Jude recently told Abbott that it was going to send out the battery alert. Abbott still expects to close its $25 billion acquisition of St. Jude by the end of the year.