Ayer's directorial debut was with the film Harsh Times, a drama set on the streets of South Central Los Angeles, showing how drug use and past military experiences affects people's attempts to lead normal lives. He then went on to direct the crime thriller Street Kings, which was released in 2008.
Ayer later wrote and directed End of Watch, a drama about the daily lives of two South Central Los Angeles policemen, played by Jake Gyllenhaal and Michael Peña. The film was released in the fall of 2012 to profitable box-office returns and favorable reception from critics, with Roger Ebert hailing it as "one of the best police movies in recent years".
Ayer wrote the submarinethrillerU-571, a fictional account of the United States capturing the Enigma code rather than Great Britain. The furor that surrounded the film's release led British Prime Minister Tony Blair to claim that it was an "affront to the memories" of those involved and U.S. President Bill Clinton to write a letter emphasizing the film's fictional nature. Ayer has said that U-571 distorted history by this assertion and that he would not do it again. "It was a distortion", he said, "a mercenary decision to create this parallel history in order to drive the movie for an American audience. Both my grandparents were officers in World War II, and I would be personally offended if somebody distorted their achievements."