ASHLAND (CBS) – A man died while competing in a triathlon Saturday morning at Hopkinton State Park.

The man, who was in his 40s, suffered a heart attack during the swim portion of the race.

READ MORE: Vaccine Booster Sites Open In Brockton And Danvers Next Week

Hopkinton State Park. (WBZ-TV)

Since it was the start of the triathlon season, medical personnel were on shore and ready to help when a lifeguard spotted the man struggling in the water.

READ MORE: Elijah Lewis Search: Large Police Presence In Abington Related To Missing 5-Year-Old Boy

“Lifeguards were in kayaks and they were following the pack. It was identified by the lifeguards that a swimmer was in distress. They approached the swimmer and realized the situation. The environmental police were also there in a boat. So they were able to get the athlete into the boat, and they moved the athlete,” said Lyn Moraghan of the Ashland Fire Department.

“They were doing a very rigorous heart massage and they were going at it nonstop,” said witness Victor Acosta. “There was a good current to bring the athletes in. It was such a perfect day- and for something so tragic to happen on a day like that.”

Emergency crews tried to resuscitate the man before he was taken to the hospital, where he was pronounced dead.

MORE NEWS: Police Arrest Woman After Service Dog Stolen From New Hampshire Walmart

The victim has not been identified.