Hundreds of soldiers saluted the flag-covered casket of a Utah mayor who was killed while serving in the National Guard in Afghanistan and whose remains were returned to his home state Wednesday.

A couple hundred motorcycle riders carrying American flags waited in salute outside the gates of the National Guard base in Salt Lake City until the hearse emerged. They revved up their engines and followed the hearse north to Taylor's hometown of North Ogden in a procession.

Taylor, 39, had taken a yearlong leave of absence as mayor for his deployment to Afghanistan, where he was training commandos as part of an effort to train and build the capacity of the Afghan national army. He was killed in a Nov. 3 attack from small arms fire by an Afghan commando he was training, military officials said.

Taylor, a military intelligence officer with Joint Force Headquarters, served two tours in Iraq and was on his second tour in Afghanistan.

He is survived by his wife, Jennie, and their seven children, ranging from 11 months to 13 years old. His family has said there is "heartache but no regret" because Taylor was trying to bring freedom to others.

Freedom: Millions Defy Taliban and Vote in Afghan Elections “The secret to happiness is freedom… And the secret to...

Posted by Brent Taylor on Sunday, October 28, 2018

His wife, Jennie Taylor, said in a statement that she wore yellow to welcome home her "hero" and "sweetheart" as women have done since World War II. She said her husband was escorted home by his brother, a fellow National Guard member.

"Major Taylor is home to his brothers In arms_his fellow soldiers in the Utah National Guard," Jennie Taylor said. "This is a tender day for all of us, and we hope you will celebrate as we do, and I'm sure Brent is, this momentous homecoming event."

The Patriot Guard Riders who organized the motorcycle group carried seven teddy bears on motorcycles — one for each of Taylor's children.

"It's the least we can do. Some of us are veterans, some us aren't, but we are all patriots and we understand and respect the ultimate sacrifice and his family gave for us," said Reed Newman, ride captain with the Patriot Guard Riders of Utah. "He's been such a patriot and such a civil servant."

A public viewing for Taylor will be held Friday night at the Dee Events Center on the campus of Weber State University in Ogden. His funeral is planned for Saturday in the same location.

Taylor became mayor in 2013 of the small city of North Ogden, a community of about 17,000 people located about 40 miles (65 kilometers) north of Salt Lake City.

He was given a local hero's farewell when he was being deployed last January with residents lining street to see him off as police escorted him and his family around the community.

In his final Facebook post that was widely shared after his death, Taylor implored Americans to vote in a message that drew a connection between democracy abroad and at home.