CAPE CANAVERAL, FLORIDA -- Spacewalking astronauts plugged a leak in a cosmic ray detector outside the International Space Station on Saturday, completing a series of complex repairs to give the instrument new life.

The $2 billion Alpha Magnetic Spectrometer could resume its hunt for elusive antimatter and dark matter by midweek.

Team members around the world expressed relief as NASA's Andrew Morgan and Italy's Luca Parmitano wrapped up work on the spectrometer. It was their fourth and final spacewalk since November to revive the instrument's crippled cooling system.

"Congratulations ... the AMS pump system is now leak tight," tweeted the European Organization for Nuclear Research, or CERN, which helps run the spectrometer.

Mission Control cautioned it was too soon to declare success with the space station's premier science instrument, but noted: "It still has a good heartbeat."

Last month, Morgan and Parmitano installed new coolant pumps on the spectrometer. They went back out Saturday to check for any leaks in the plumbing.

Parmitano quickly discovered a leak in one of the eight coolant lines -- the first one he tested -- and tightened the fitting. "Our day just got a little more challenging," Mission Control observed.

The line still leaked after a mandatory one-hour wait, and Parmitano tightened it again. Finally, success -- the leak was gone. "Let us all take a breath," Mission Control urged. By then, the astronauts were already halfway into their six-hour spacewalk.

Mission Control acknowledged the leak added some unwanted "drama" to the spacewalk. "Everybody's hearts stopped," Mission Control told the astronauts. Parmitano wondered aloud what his heart rate was when the leak erupted. "It either flat-lined or spiked, one of the two."

"It was hard fought today, really well done. Cool heads prevailed," Mission Control said as the spacewalk drew to a close.

Barring further trouble, the spectrometer -- launched to the space station in 2011 -- will have its coolant lines filled with more carbon dioxide Sunday. One pump will be turned on as early as Monday and the remaining three Tuesday. That could lead to the resumption of science observations by Wednesday.

NASA described the spectrometer spacewalks as the most complicated since the Hubble Space Telescope repair missions a couple decades ago. Unlike Hubble, this spectrometer was never intended for astronaut handling in orbit, and once it started faltering in 2014, it took NASA years to devise a repair plan.

Morgan and Parmitano had to cut into stainless steel pipes to bypass the spectrometer's old, degraded coolant pumps on a previous spacewalk. Then they spliced the tubes into the new pumps -- no easy job when working in bulky gloves. New tools had to be created for the intricate job.

"We did it. We all did it," Morgan said once he was back inside.

Astronaut Jessica Meir noted that the day ended up being more interesting than anyone envisioned. "But you guys rolled with all the punches and got the job done.. ... Dinner is waiting," she said.

The massive 7 1/2-ton (6,800-kilogram) spectrometer was launched to the space station on NASA's next-to-last shuttle flight. Until it was shut down late last year for the repair work, it had studied more than 148 billion charged cosmic rays. The project is led by Samuel Ting, a Nobel laureate at the Massachusetts Institute of Technology.

The repairs should allow the spectrometer to continue working for the rest of the life of the space station, or another five to 10 years. It was designed to operate for only three years.

NASA's two other astronauts on board, Meir and Christina Koch, performed two spacewalks over the past 1 1/2 weeks to upgrade the space station's solar power system.

Altogether, this station crew went out on nine spacewalks -- or 61 hours in total. That's more than any other station expedition.

Parmitano, Koch and Russian Alexander Skvortsov return to Earth in less than two weeks.

------

The Associated Press Health and Science Department receives support from the Howard Hughes Medical Institute's Department of Science Education. The AP is solely responsible for all content.