Edwin Allan Lightner Jr., 82, a 40-year U.S. diplomat who saw the Berlin Wall erected and took part in a Cold War prisoner exchange with the Soviet Union, died Saturday at his home in Northport, Maine. The New York native joined the foreign service after graduating from Princeton University in 1930. He served in 18 countries before retiring in 1970. His last foreign post was ambassador to Libya from 1963 to 1965. He had been charge d'affaires of the U.S. Embassy in South Korea and was assistant chief of the U.S. Mission in Berlin when the wall was erected in 1961. He was twice detained by East German border guards in October 1961 when he crossed into East Berlin to underscore the United States' determination to have unrestricted access to all occupation zones in Berlin. He also participated in the Berlin exchange of Francis Gary Powers, the American U-2 pilot shot down during a reconnaissance flight over the Soviet Union in 1960.