BATON ROUGE, La. — Family, friends and close comrades came Friday to pay their last respects to Matthew Gerald, a 41-year-old rookie police officer and one of three officers slain by a gunman who was targeting the police.

But many of the spots in the 2,500-seat megachurch here were packed with people who never knew Officer Gerald — though they knew, intimately, of the perils he faced. The officers and sheriff’s deputies came from around the country in their crisp, formal finery — all aiguillettes and polished shoes, Stetsons and broad-brimmed campaign hats. They came from Los Angeles County; Madison, Wis.; and Mesa, Ariz. An officer came from French Settlement, a Louisiana village of just over a thousand residents near the Amite River. A pair of Royal Canadian Mounted Police officers came, almost exotic in their blazing red serge.

It was a measure of the regard for Officer Gerald’s sacrifice, and a dramatic testament to the wide and unsettling reverberations set off by the killing of the three officers here on Sunday. Officer Gerald was the first to be buried. His funeral at Healing Place, a suburban church he attended with his family, began with an honor guard draping his coffin with an American flag.

“I pray for every law enforcement officer,” Ken Spivey, a deputy and chaplain with the nearby Ascension Parish sheriff’s office, told the crowd — not just the officers in this corner of Louisiana, Deputy Spivey added, but all across the nation. “Because they’re under attack.”