After hearing a day and a half of testimony, a federal judge on Thursday abruptly dismissed a lawsuit brought against Temple University by a former student who alleged that his professors retaliated against him for his political views.

The student, Christian M. DeJohn, sued the university and two of his professors in February 2006, contending that the professors had thwarted his efforts to finish a master's degree in history after he complained about receiving "antiwar" e-mail messages that were circulating in the history department.

The professors were Richard H. Immerman, director of the university's Center for the Study of Force and Diplomacy, and Gregory J.W. Urwin, a professor at the military-history center and Mr. DeJohn's former academic adviser. The professors argued in court that Mr. DeJohn's difficulties in finishing his degree were entirely his own. In an interview, their lawyer, Joe H. Tucker Jr., described Mr. DeJohn as a "marginal learner, barely passing" his courses, who had turned in a master's thesis that had "flabbergasted" the professors.

The judge, Stewart Dalzell of the U.S. District Court in Philadelphia, said that Mr. DeJohn's lawyers had presented no evidence that Mr. Immerman retaliated against the student. And the judge said that, while the jury may have discerned some evidence that Mr. Urwin had retaliated against Mr. DeJohn, the professor deserved "qualified immunity," which means that he behaved toward Mr. DeJohn in a way that could reasonably be seen as within his rights....