The gunman was identified as a member of the Afghan National Defense and Security Forces. A statement from Nato said the attacker was killed by Afghan forces.
Major general Jefferson S Burton, of the Utah National Guard, told reporters Taylor's mission was to build the capacity of the Afghan national army as part of the advisory team.
"He was with folks he was helping and training. That's what's so painful about this. It's bitter," Mr Burton said. "I do believe that Major Taylor felt he was among friends, with people he was working with."
Officials said another US military member whose name was not immediately made public was wounded in Saturday’s attack.
The Pentagon confirmed it had launched an investigation into the incident, but released no further details.
Taylor was elected as mayor of North Ogden, north of Salt Lake City, in 2013 and was expected to return to the job in January.
He had served two tours in Iraq and was on his second tour in Afghanistan at the time of his death.
Paying tribute on Twitter, US senator Orrin Hatch of Utah said: “Brent was a hero, a patriot, a wonderful father, and a dear friend. News of his death in Afghanistan is devastating. My prayers and love are with Jennie and his seven young children. His service will always be remembered.”
Taylor's remains are scheduled to arrive at Dover Air Force Base in Delaware on Monday evening.
Additional reporting by AP
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies