"We are counting on you," Mr. Obama said from an outdoor courtyard at FBI headquarters, where he was greeted by sustained cheers.
Thousands crammed the plaza, while many other FBI workers peered down from their windows. Mr. Obama thanked them all for embracing "a profound transformation" in their mission and their capabilities.
"With the attacks of 9/11, your mission became focused more than ever before on prevention, so that we have the capacity to uncover terrorist plots before they take hold," he said. "With the spread of new technologies you increasingly confronted adversaries in unconventional areas, from transnational networks to cybercrimes and espionage. And through it all, you must continue to stay one step ahead of all who step outside of the law."
Mr. Obama's brief stop at the FBI was part of a broader effort in support of the crime-fighting and intelligence community. He went to the CIA last week in a morale boost for employees after controversy erupted over his decision to release Bush-era memos detailing harsh interrogations methods against terror suspects.
At the start on Tuesday, Mr. Obama got a big burst of applause when he donned the FBI cap given to him by the bureau's director, Robert Mueller.
On a more sober note, the president warned of a long struggle against al Qaeda terrorists.
He repeatedly said the FBI protects both U.S. security and ideals, rejecting what he called a "false choice" between preserving one or the other.
"We know that al Qaeda is not constrained by a constitution or by allegiance to anything other than a hateful ideology and a determination to kill as many innocents as possible," Mr. Obama said. "But what makes the United States of America so special is precisely the fact that we are willing to uphold our values and our ideals, not just when it's easy but when it's hard."
The president said he knew the bureau's mission was difficult.
"Many of you made enormous sacrifices and are incredibly dedicated," Mr. Obama said. "Living our values means that we must hold ourselves to higher standard than our enemies. We face a long struggle against a determined adversary."