An off-duty San Francisco firefighter may have saved a life Saturday morning when he aided with the rescue of a swimmer who had been struggling in the cold water of the bay.

Capt. Thomas Johansen was swimming about 9:20 a.m. at Aquatic Park in San Francisco when he saw the Police Department’s Marine Unit responding to a swimmer in distress, said Lt. Jonathan Baxter, a spokesman for the San Francisco Fire Department.

The victim, a 56-year-old man from out of town, was participating in the annual Alcatraz Sharkfest Swim, which normally begins at Alcatraz Island and ends at Aquatic Park, but this year was moved into the cove at Aquatic Park because of high winds on the bay. The police’s Marine Unit, the Coast Guard and medical staff were on hand to help at the event, Baxter said.

Rescue crews “noticed the male in distress near a kayak” during a routine patrol, Baxter said.

Johansen, who wasn’t part of the event and was swimming for the exercise, immediately swam over when he saw the commotion.

Together, Johansen and the emergency crew moved the man onto the platform behind the Police Department’s boat and began CPR. When they arrived on shore, paramedics continued with “advanced life support” until they were able to restart the man’s heart, Baxter said.

The man, whose name was not released, was transported to California Pacific Medical Center for a critical medical issue, Baxter said.

The police’s Marine Unit “probably even saved this guy’s life. Once you go underwater into the bay, it’s super hard to locate and retrieve the victim,” Baxter said.

As for Johansen, “he’s so modest,” Baxter said, quoting Johansen as saying, “I was just swimming. I did what everybody else would do.”

Baxter added: “That’s what public servants do. Public servants take the job because they want to help.”

Sarah Ravani is a San Francisco Chronicle staff writer. Email: sravani@sfchronicle.com Twitter: @SarRavani