GERHARD A. GESELL, the unpredictable 79-year-old Federal District Judge who presided over the Iran-contra trial of Oliver L. North, saved a final surprise for last by punishing Mr. North for his crimes with a sentence that included a fine, community service and probation, but no prison term.

Mr. North's admirers and his detractors had expected much harsher treatment, considering Judge Gesell's oft-spoken respect for adherence to the law, the seriousness of the charges and a recommendation by the independent prosecutor, Lawrence E. Walsh, that Mr. North serve time in jail. In addition, Judge Gesell had shown no reluctance to send highly placed Government officials to prison when he presided over several Watergate-related trials in the mid-1970's.

Mr. North, the former Marine Corps lieutenant colonel and National Security Council aide, was convicted of destroying documents, accepting the gift of a $13,800 home security system and abetting the obstruction of Congress. Judge Gesell could have imposed a maximum penalty of 10 years in prison and fines of $750,000. Instead, he imposed a $150,000 fine, two years of probation, a three-year suspended sentence and an order to perform 1,200 hours of community service.

The leniency of the sentence left prosecutors stalking from the courthouse without comment. And there was scattered criticism from liberal Democrats, such as Representative Howard M. Metzenbaum of Ohio, who said the sentence was a ''disappointing surprise.'' But some other Democrats, including Representative Lee H. Hamilton of Indiana, one of Mr. North's harsher critics, found nothing to criticize about the punishment. Mr. Hamilton, chairman of the House panel that investigated Iran-contra, said the sentence was ''good and wise.''