Ryan produced a phenomenal diving effort to tip the ball away for a corner - reminiscent of the so-called save of the century English goalkeeper Gordon Banks produced from Brazil's Pele at the 1970 World Cup.
Minus several key players and resting arguably their most effective forward this season, Mate Dugandzic, the third-placed Heart destroyed the Mariners throughout the first half and most of the second with slick ball movement.
Terra was at the centre of most of their moves as they lined up with a back three, and the Mariners looked cumbersome and exposed for one of the few times in an unbeaten run which now stretches to 14 games.
Terra first tested Ryan after 13 minutes, with the keeper sprawling effectively to deny him.
The Brazilian striker then found a way past Ryan for the first and only time in the match on 28 minutes, when his dipping, long-range effort hit the post.
Ryan also managed big saves from Rutger Worm on 56 minutes, Terra again a minute later, then once more denied Behich with 10 minutes remaining as it became clear there would be no way past the Central Coast keeper.
He also tipped over a long-range Worm shot, before the Mariners worked one of their few decent attacking moves to find Kwasnik unmarked at the far post to bang in a winner as the clock ticked down.
The Heart remain third, just a point clear of fourth-placed Wellington Phoenix, but have not won in their past four outings.
Mariners coach Graham Arnold credited Ryan's performance with saving his side, and admitted he was unhappy with what they produced in the top-of-the-table clash.
"We got three points we didn't deserve tonight,'' Arnold said.
"Melbourne Heart were the better side, they had more chances, played better football.
"I'm not happy. We got three points but it's not the performance I want.''
Heart coach John van't Schip was disappointed but philosophical with his side's defeat, which mattered little in ladder context given Sydney FC and Perth Glory's 1-1 draw earlier on Wednesday night.
"We played well for big parts of the game ... to lose a game at the end is very hard,'' van't Schip said.
"I can only give big compliments to all the boys, but for the three points, it wasn't good enough.''
The Mariners back up at home against in-form Adelaide United on Saturday night - when the Heart also host second-placed Brisbane Roar.
- AAP