Updated

Baton Rouge Police Officer Matthew Gerald was remembered as a hero Friday by the city's mayor, who called for respecting the police and avoiding the kind of "us vs. them" mentality that can encourage violence.

More than 2,000 people packed the church where Mayor Kip Holden and other leaders eulogized Gerald, the first of three officers slain by a lone gunman to be laid to rest. More funerals follow Saturday and Monday.

"The men and women who put on those uniforms, they respect you. Respect them," the mayor said.

Baton Rouge Police Chief Carl Dabadie Jr.'s voice cracked as he strayed from his prepared remarks to respond to the criticism police across the country have received over a steady stream of videotaped killings of black people by police.

"The media has blasted us for what we do and how we do it, basically portraying law enforcement as these band of bullies who go around and beat people up," the chief said. "We're not bullies. We are protecting our communities. And they throw us under the bus for it. And that's wrong."

Two of Gerald's uniforms hung next to his flag-draped casket as photos on a big screen showed moments from his 11 years in the military, his fledging police career and his family life.

Dechia Gerald, now a widow with two young girls, called him "my blue-eyed rock" in a written tribute, expressing hope that his legacy will "bridge the gap and foster peace in the country he lived, loved and died for."

Funerals for sheriff's deputy Brad Garafola and police officer Montrell Jackson are set for Saturday and Monday. They too were slain by Gavin Long, an Army veteran who urged violence in response to what he saw as the oppression of black people.

After killing three officers and wounding three more on Sunday, Long was killed with a long-distance shot by a SWAT team officer.

Police said the attack shattered days without significant violence in Baton Rouge, even as thousands protested amid heightened racial tension following the police shooting of Alton Sterling, a black man whose death was recorded and posted online.

The two officers involved in Sterling's death were put on administrative leave and the U.S. Justice Department is investigating, but the streets have been busy with people demanding an end to police shootings of black men.

The funeral's speakers included Gerald's childhood friend Dave Mulkey, who described sending him a text message during the protests over Sterling's death.

"I told him to be careful, and to keep a cool head," Mulkey recalled. He said Gerald's response was "I'm going to do what I got to do to keep you all safe, old boy."

Gerald joined the Baton Rouge Police Department less than a year ago, an enthusiastic rookie at age 41, after serving four years in the Marines and seven years in the Army, where he did three tours in Iraq and ran a Blackhawk helicopter crew.

He was partnered with Cpl. Lester Mitchell, an 11-year police veteran. The two officers, black and white, began riding together on July 1, days before Sterling's death.

"We talked about the madness, how much it was putting a strain on the community, police relations," Mitchell said Friday. Gerald, he said, "was a protector. It was just in his DNA."

He said they were writing reports at police headquarters Sunday when Gerald said he was going for an energy drink at the B-Quick convenience store a few blocks away.

Someone at the store approached Gerald, saying an armed man was walking through the area, Mitchell said. Gerald radioed for help, and Mitchell was among the officers who raced to the scene, hearing gunfire as they arrived.

"We were right in the middle of the firestorm," he said. "He had already been shot when we got there."

The many mourners Friday included Sheriff's Capt. Tom Cox from Knox County, Tennessee. He said he attended all five funerals for the officers killed by a sniper in Dallas this month, and planned to attend all three of the funerals in Louisiana.

"It's numbing, with this many in such a short period of time" Cox said. "We hope this isn't some trend."