WASHINGTON — Gina Haspel, the director of the Central Intelligence Agency, made a rare public appearance on Thursday to give a nostalgia-laced recruiting pitch to students at Auburn University. But she was confronted instead by a heckler shouting about her role in torturing suspected militants in the years after the Sept. 11 attacks.

Ms. Haspel was recounting the excitement she felt at the start of her own career when the heckling began. “Tell these young children, tell them who you tortured. You know their names — they’re still in Guantánamo Bay,” an unidentified man shouted.

“You’re a decrepit human being,” he continued before being removed by security. “The only people you should be talking to is a prison guard in a jail cell.”

The C.I.A. has strenuously sought to distance Ms. Haspel from the now-defunct torture program since 2017, when she was named the agency’s deputy director; she ascended to the top job nearly a year ago. In her speech on Thursday, Ms. Haspel talked about the C.I.A.’s efforts to change with the times — to diversify, to bring in recruits with new technology and language skills, and to refocus on the business of spying on rival powers after years of being deeply enmeshed in the fight against Islamist militants.