Walter Reed Martindale III, the former State Department official on trial on charges of plotting to kill a Saudi sheik, testified yesterday that he does not know how he wound up illegally transporting a gun out of the country last year.

"I didn't do anything illegal and I had no intention of doing anything illegal," Martindale said during nearly six hours of testimony in U.S. District Court in Alexandria.

Martindale, 41, looking harried and tired toward the end of the day, for the first time yesterday publicly gave his account of the events that led to his arrest a year ago for taking an Uzi semiautomatic rifle to London.

As a result of that arrest and Martindale's subsequent conviction, the U.S. government launched an investigation that resulted in a nine-count indictment against Martindale this summer that charged him with plotting to kill Mohammed Fassi, a member of the Saudi royal family.

Martindale, a resident of the Hollin Hills section of Fairfax County, south of Alexandria, testified yesterday that he had obtained the Uzi rifle at the request of Ibrahim Rawaf, his partner in their Washington-based American International Trade Group.

Martindale said that he had left the gun at Rawaf's Alexandria town house last summer and was later told by Rawaf that the gun had been given as a gift to an Arab business associate.

Martindale said he found a semiautomatic Uzi, later identified as the one he had obtained for Rawaf, in a package he was asked to take with him during a trip to London last year. The package, given to him by a Lebanese acquaintance he cannot identify, was to have contained radios, according to Martindale.

"I even asked the guy, 'This is nothing illegal?' " Martindale recalled.

Rawaf is also indicted in the alleged conspiracy but remains a fugitive in Lebanon.

Martindale could receive up to 50 years in prison and a $36,000 fine if convicted on the conspiracy and gun charges and of impersonating a U.S. diplomat by using his old State Department passport. Attorneys for both sides are scheduled to give closing arguments before the case goes to the jury.

Martindale's appearance yesterday concluded three days of testimony in the trial, during which the government alleged that Martindale planned to assassinate Fassi, then living in London.

Scott Goodman, the government's key witness and a former military adviser who worked with Martindale in Vietnam, testified earlier this week that Martindale asked him to help plan the murder and that the two traveled to London to conduct surveillance of Fassi's home. Goodman has been granted immunity for his testimony in the case.

Defense attorneys yesterday focused on Martindale's record as a "humanitarian," who was among the last U.S. officials to leave Vietnam after the fall of Saigon.

Attorney Paul R. Kramer of Baltimore questioned Martindale for nearly an hour on his client's work in helping Vietnamese refugees leave that country and the numerous awards and commendations he received as a result.

Kramer also produced documents of a proposed business plan by Martindale's firm to provide security to rich Arabs. Martindale has contended that he photographed Fassi's home and vehicles while in London, and made detailed notes about the sheik's comings and goings, as part of the business proposal.

At the close of testimony yesterday, the trial had generated as many questions as it had answered, particularly about the identity of the contractor in the alleged murder plot.

Goodman had testified earlier that a high Saudi official was believed to be providing them with money for the alleged scheme. Yesterday, Martindale said a high Saudi official involved in internal and external intelligence was interested in financing his firm's security project because of concern about "worldwide malcontents and terrorists."