A US mayor has been killed in an apparent insider attack while serving with the military in Afghanistan.

Brent Taylor, 39, died in Kabul on Saturday while serving in the US Army National Guard helping to train members of the Afghan security forces.

The mayor of North Ogden, Utah, leaves behind a wife and seven young children.

Another service member was wounded during the shooting, the second insider attack against US forces in Afghanistan in the past two weeks.

The attacker appeared to have been a member of the Afghan National Defence and Security Forces, according to the Utah National Guard.

He was shot by other Afghan forces after opening fire.

In a statement from Taylor's family, they thanked the public for the "outpouring of love and support during this unspeakably difficult time".

"As one of many, many military families to give the ultimate sacrifice we also want to express our love for this great nation and the pride that we feel knowing that Brent gave his life in service to his country," the statement continued.

Speaking outside the family home, which was adorned with American flags, his sister-in-law Kristy Pack said: "We are overwhelmed with heartache, but not regret."

Mr Taylor, who held the Army rank of major, enlisted in the military after the 11 September 2001 attacks, along with his five brothers.

Before his final tour, he had served twice in Iraq and once before in Afghanistan.

He was elected to the city council of North Ogden - a suburb of 19,000 residents north of Salt Lake City - in 2009 and was first elected mayor in 2013.

According to his official biography, he took a temporary leave of absence in order to redeploy.

A fundraiser for his wife and seven children - ages 11 months to 13 years old - has raised nearly $250,000 (£192,000) by Monday.

'Exercise the right to vote'
While in Afghanistan he kept up a steady stream of Facebook posts, and in a final post on 28 October he praised Afghans for voting in their first parliamentary election in years.

The Republican politician then mentioned his own country's mid-term elections, due to be held on Tuesday.

"As the USA gets ready to vote in our own election next week, I hope everyone back home exercises their precious right to vote," he wrote.

"And that whether the Republicans or the Democrats win, that we all remember that we have far more as Americans that unites us than divides us."

What US forces are currently in Afghanistan?
American combat operations against the Taliban officially ended in 2014, but some US troops remain in the country to provide training and assistance to Afghan forces.

Last year, US President Donald Trump signalled he would keep US boots on the ground indefinitely amid concerns that the Taliban was gaining ground.

The US forces are part of the Nato-led Resolute Support Mission in Afghanistan, which has more than 16,000 personnel.