* Army units take over police buildings
* Prime Minister Thabane calls action "military coup"
* Says he in South Africa, will return when safe
* Army denies coup, says moved against rogue police elements
* South Africa, SADC, expected to oppose any coup (Adds Thabane telling BBC he fled to South Africa, reported casualties)
By Marafaele Mohloboli
MASERU, Aug 30 (Reuters) - Lesotho's Prime Minister Thomas Thabane on Saturday accused his country's army of mounting a coup against him and said he had fled to South Africa, but the military denied seeking to oust him and said its soldiers had returned to barracks.
Gunfire was heard in Maseru, capital of the small mountainous Southern African kingdom encircled by South Africa, and army units occupied police headquarters and surrounded the prime minister's residence, residents and diplomats said.
"It is a military coup because it is led by the military. And the military are outside the instructions of the commander in chief, who is myself," Thabane told South Africa's ENCA TV by telephone.
Thabane told the BBC he had fled to neighbouring South Africa. "I will return as soon as my life is not in danger," he said. His precise location was not immediately known.
Thabane said he would meet South African leaders, representing the regional Southern African Development Community (SADC) later on Saturday to discuss the crisis in Lesotho, which followed tensions between rival factions of the two-year-old governing coalition.
Residents and diplomats said that heavily-armed soldiers had surrounded State House and also occupied the main headquarters of the police force, which is loyal to Prime Minister Thabane.
The diplomats said that the army was mostly loyal to Deputy Prime Minister Mothetjoa Metsing, who had vowed to form a new coalition that would oust Thabane, who in June suspended parliament to avoid a no-confidence vote.
Giving its version of events, the Lesotho Defence Force denied attempting a coup against Thabane, saying it had moved against police elements suspected of planning to arm a political faction, an army spokesman said.
"There is nothing like that, the situation has returned to normalcy ... the military has returned to their barracks," Major Ntlele Ntoi told Reuters. He added the military "supports the democratically-elected government of the day."
Ntoi said one soldier and four police had been injured during the army action.
Diplomatic sources said the army made its move after the prime minister had fired the army commander, Lt.-Gen. Kennedy Tlali Kamoli. The army spokesman said Kamoli was still in charge of the military.
Residents said the streets of the capital were calm, although some shops remained closed.
South Africa and regional grouping SADC were expected to issue a call for calm and warn the Lesotho political rivals that no unconstitutional change of government would be tolerated.
Since independence in 1966, Lesotho has undergone a number of military coups. In 1998 at least 58 locals and eight South African soldiers died and large parts of Maseru were damaged during a political stand-off and subsequent fighting.
Besides textile exports and a slice of regional customs receipts, Lesotho's other big earner is hydropower exported to South Africa from the massive mountain ranges that have made it a favourite of trivia fans as "the world's highest country" - its lowest point is 1,380 metres (4,528 feet) above sea level. (Additional reporting by Peroshni Govender, Joe Brock, Helen Nyambura and Pascal Fletcher,; Writing by Pascal Fletcher; Editing by Joe Brock)
Our Standards: The Thomson Reuters Trust Principles.