Philip Agee, the former Central Intelligence Agency officer who turned against the agency and spent years exposing undercover American spies overseas, died Monday in Havana. He was 72.

The cause was peritonitis, said Louis Wolf, a friend.

Mr. Agee, whose disillusionment with his work at the agency led him to embrace leftist views, had spent nearly four decades as an avowed enemy of American foreign policy and particularly of the covert intelligence work that supported it. Deprived of his American passport and expelled from several countries at the request of the United States, he had lived for the most part in Germany and Cuba, where he operated a travel Web site, cubalinda.com.

His 1975 book, “Inside the Company: CIA Diary,” infuriated American officials by identifying about 250 officers, front companies and foreign agents working for the United States. His example inspired several more books and magazines, including Covert Action Information Bulletin, written by close associates and sometimes with Mr. Agee’s help, which published the names and often the addresses of hundreds more agency officers working under cover around the world.

The exposés of Mr. Agee and others led Congress to pass the Intelligence Identities Protection Act of 1982, which made it a crime to intentionally reveal the identity of a covert intelligence officer. An investigation of the possible violation of that law in 2003 after Valerie Wilson was named as a C.I.A. officer led to the perjury conviction last year of I. Lewis Libby, Vice President Dick Cheney’s former chief of staff.