Robert A. Pastor, a White House aide under President Jimmy Carter who shepherded the 1977 Panama Canal treaties to ratification — and was punished for it 17 years later, when conservatives defeated his nomination to be ambassador to Panama. Mr. Pastor went to work for President Carter as the National Security Council’s expert on Latin American affairs at age 29, the day after he finished his examination for a Ph.D. from Harvard. After helping to formulate policies in tumultuous Central America and elsewhere, he worked for the Carter Center, which promotes human rights and oversees elections. Later, Mr. Pastor taught at Emory and American Universities, wrote or edited 17 books, and traveled the world, from Haiti to China, to mediate elections. His involvement with Panama began when he was staff director of the bipartisan Commission on U.S.-Latin American Relations from 1975 to 1977. The commission found that the most serious challenge in the region was resentment over the United States’ exercising virtual sovereignty over Panamanian territory. Mr. Carter, newly elected, accepted the analysis. In that role, Mr. Pastor participated in the negotiations to return the Panama Canal Zone to Panama and helped persuade the Senate to pass the treaties. In 1994, when President Bill Clinton nominated Mr. Pastor to be ambassador to Panama, many conservatives remained critical of the loss of the canal. Senator Jesse Helms, Republican of North Carolina, who headed the Foreign Relations Committee, prevented Mr. Pastor’s nomination from being voted on by the full Senate even though his committee had approved it, 16 to 3. Mr. Pastor asked that his nomination be withdrawn in 1995. Administration officials told The New York Times that he would almost certainly have been approved had the nomination come to a Senate vote. (The post ultimately went to William J. Hughes, a former Democratic congressman from New Jersey.) In more recent years, Mr. Pastor’s advocacy of greater cooperation among Canada, Mexico and the United States, in commerce and other areas, also riled conservatives, who said his ideas threatened national sovereignty. Mr. Pastor countered that he envisioned a North American “community,” not a “union.” Robert Alan Pastor was born in Newark on April 10, 1947, graduated from Lafayette College, and served in the Peace Corps in Malaysia. In addition to his Ph.D., he earned a master’s degree at Harvard. His far-flung career included helping to found, in 1985, the Council of Freely Elected Heads of Government, a group of 32 presidents and prime ministers from the Americas; helping to arrange a cease-fire between Israel and Hamas, the Palestinian militant group, in 1996; and advising Democratic candidates. He was executive director of the Commission on Federal Election Reform headed by Mr. Carter and James A. Baker III, the former secretary of state. Besides his son Robert, who is known as Kip, he is survived by his wife, the former Margaret McNamara (a daughter of Robert S. McNamara, the former defense secretary); his daughter, Tiffin Pastor Eisenberg; his brothers, Donald and Bruce; and a grandson.