By Jim Forsyth

SAN ANTONIO (Reuters) - More than 1,000 mourners, including police from across the country, attended the funeral on Monday of a San Antonio police officer fatally shot this month in his squad car during a routine traffic stop outside the city's police headquarters.

Benjamin Marconi, a 20-year veteran of the San Antonio police force, was killed at age 50 in a Nov. 20 ambush attack. He was remembered as a dedicated officer who wanted to help others.

"Detective Marconi, we are forever grateful for your watch. He was a friendly dear brother and he was a friend to so many who served this city so well," said Betsy Buhler, a pastor at Community Bible Church, which held the funeral.

Floral arrangements with Marconi's badge number also adorned the church in San Antonio.

Suspect Otis McKane was arrested without incident a day after the shooting and charged with capital murder, which can bring the death penalty in Texas.

McKane, 31, apologized to the officer's family in comments to reporters after being arrested, saying he had "lashed out at somebody who didn't deserve it" in anger over a child custody dispute.

The detective was shot twice in the head as he wrote a traffic ticket after pulling over another motorist. Authorities said McKane then stopped his car behind Marconi's vehicle, walked up and shot the detective through the window.

His death came roughly four months after five police officers were killed by a black gunman in a racially motivated ambush in Dallas that stoked concerns about officer safety and fueled a simmering debate about the role of race in U.S. policing.

(Reporting by Jon Herskovitz and Jim Forsyth; Editing by Will Dunham and Marguerita Choy)