TMZ has the audio of Pete Davidson skillfully handling a heckler who tried to jab at the comedian's personal life by yelling out Mac Miller's name at a highly inappropriate time.

The 'SNL' star was performing Monday night at the South Orange Performing Arts Center in New Jersey when he started the setup for a joke, saying ... "My friend died in my apartment."

That's when some tool in the audience yelled, "Mac Miller?"

Listen to the audio ... Pete immediately stopped everything and urged the crowd to point out the "f***face" so security could remove him. He refused to continue the show until the guy was tossed ... which he did once the audience dimed him out.

Davidson made sure the heckler got his money back -- because he said he didn't want it -- and reeled the crowd back in ... with a Dane Cook joke.

Well played.