Image copyright Getty Images Image caption Michelle Obama is the first African American to be First Lady

The mayor of a town in the US state of West Virginia has resigned after she was caught up in a controversy over racist comments about Michelle Obama.

Beverly Whaling had appeared to applaud a Facebook post referring to Mrs Obama as an "ape in heels".

She wrote that the post had made her day, but later said she was referring to the election outcome.

A petition calling for the mayor's resignation had gathered over 170,000 signatures.

Ms Whaling was the mayor of the town of Clay, which has a population of just 491.

The town has no African American residents, according to the 2010 census. In Clay County as a whole, more than 98% of its 9,000 residents are white.

Image copyright White House Image caption The future and current first ladies, Melania Trump and Michelle Obama, met last week

Ms Whaling had responded to a Facebook post by Pamela Ramsey Taylor, a local resident who runs a non-profit group in Clay County, which referred to the first lady as an "ape".

"It will be refreshing to have a classy, beautiful, dignified first lady in the White House. I'm tired of seeing a Ape in heels," Ms Taylor wrote.

Ms Whaling responded with "just made my day Pam".

Read more on the US election aftermath:

Was summer of liberalism really the dawn of Trump?

Clinton supporters find comfort in Pantsuit Nation Facebook group

Twitter suspends alt-right figureheads

While Clay County has a small population, the furore over the Facebook post spread far and wide.

Ms Taylor had already been dismissed from her post.

Image copyright WSAZ Image caption The Facebook post was first spotted by local news channel WSAZ3

Ms Whaling had already issued a written apology to news media outlets saying that her comment wasn't intended to be racist.

"I was referring to my day being made for change in the White House! I am truly sorry for any hard feeling this may have caused! Those who know me know that I'm not in any way racist!"

A statement from the council apologised to Mrs Obama and condemned the post as "horrible and indecent''.

"Please don't judge the entire community for one or two individual acts,'' councillor Jason Hubbard said.

Another council member Joyce Gibson extended an invitation to anyone who judged the community to "come see us... spend a day with us".

"If I knew you would come, I would bake a cake. We're very decent people,'' she added.