Neil Patrick Harris had to complete a 22-foot dive to try and win a free gym membership.

The 'How I Met Your Mother' star competed in the inaugural Equinox Goldrush swimming challenge in Montauk, New York, last Friday (17.07.15) with the winner earning a paid-up membership to the swanky fitness club chain.

Harris - who is married to David Burtka - battled 11 other competitors in the contest which saw them have to complete the dive into Fort Pond and race in a 300-yard swim as well as three other challenges.

Unfortunately for the 42-year-old actor he was not crowned the champion but graciously congratulated the winner and stayed on for the after-party, happily mingling with other guests at the Surf Lodge.

The perks of the free one-year gym membership - which usually costs $225-per-month - include access to over 75 Equinox clubs worldwide, one free 50-minute massage per month, 24 free personal training sessions and a $1,000 gift card to use in the chain's various shops.