WASHINGTON (AP) — Former White House national security adviser Robert C. McFarlane, a top aide to President Ronald Reagan who pleaded guilty to charges for his role in an illegal arms-for-hostages deal known as the Iran-Contra affair, has died. He was 84.

McFarlane, who lived in Washington, died Thursday from complications of a previous lung condition at a hospital in Michigan, where he was visiting family, according to The Washington Post and The New York Times.

McFarlane, a former Marine lieutenant colonel and Vietnam combat veteran, resigned his White House post in December 1985. He was later pressed into service by the administration as part of secret — and illegal — plan to sell arms to Iran in exchange for the freedom of Western hostages in the Middle East and pass along the proceeds to the contra rebels in Nicaragua for their fight against the Marxist Sandinista government.

Also read | Llyod Austin holds 1-hour call with Sergei Shoigu: What they discussed

He played a major role in the affair, leading the secret delegation to Tehran, then as now a U.S. adversary, to open contact with so-called moderate Iranians who were thought to hold influence with kidnappers of American hostages. He brought with him a cake and a Bible signed by Reagan.

The scheme began to unfold a after a cargo plane carrying a CIA-arranged shipment of arms was shot down in October 1986 by the Sandinistas in Nicaragua, setting off what eventually became one of the biggest modern political scandals.

McFarlane was rushed to a Washington-area hospital in February 1987 after taking an overdose of Valium the day before he was scheduled to testify before a presidential commission investigating the affair.

Also read | India declares 1-day state mourning after UAE President’s death: Here’s what it means

He pleaded guilty in March 1988 to four misdemeanor counts of withholding information from Congress, readily admitting his role in the affair.

″I did indeed withhold information from the Congress,” he told reporters at the time. “I believe strongly that, throughout, my actions were motivated by what I believed to be in the foreign policy interest of the United States.″

He was pardoned by President George H.W. Bush, along with five other figures from the scandal.

Also read | Who was Bruce McVittie, ‘Sopranos’, ‘Sex and the City’ actor, dead at 65

McFarlane, a career Marine known as “Bud” to his friends, had risen to lieutenant colonel and to positions in the Nixon and Ford administrations. He served as national security special assistant to Richard M. Nixon and Gerald R. Ford during their presidencies.

During the Carter administration, he was on the Republican staff of the Senate Armed Services Committee. He returned to the executive branch with Reagan’s election, serving as a State Department counselor until moving to the White House as national security adviser William Clark’s deputy in January 1982. He was appointed to the top national security post in 1983.

McFarlane, a graduate of the U.S. Naval Academy, was the son of a former Democratic congressman from Texas, William Doddridge McFarlane, who served from 1932 to 1938. He is survived by his wife, two daughters and a son.