Bangkok, Thailand (CNN) -
The Thai military has announced it has taken control of the country in a coup, the country's military chief announced in a national address Thursday.
A Thai election official said the country's caretaker prime minister and his Cabinet should resign and a new interim government should be named ahead of elections to be held in six to nine months.
The election official pitched the idea Wednesday at a meeting aimed at finding a solution to the martial law imposed by the Thai military, a source close to the interim prime minister told CNN Thursday.
But interim Prime Minister Niwatthamrong Boonsongpaisan said there's no chance that the caretaker government will resign.
"This can't be done because it is illegal," a statement from Niwatthamrong's office said. "To find (a) solution, (it) must be done accordingly to laws and under the constitution."
Thursday is the second day of talks between the military and opposition groups.
In addition to finding a way to end the martial law, the talks also aim to restore a functioning government, a source close the interim prime minister said.
The first day of talks Wednesday ended without an agreement.
Among those invited to the meetings this week are the chairman of the election commission, the acting senate house speaker, the leader of the governing Pheu Thai party, the leader of the opposition Democrat Party, the leader of the anti-government protesters and the leader of the pro-government "red shirts."
Deep-seated tensions in Thailand in recent months have caused deadly clashes, paralyzed parts of the capital city and brought down Prime Minister Yingluck Shinawatra.
Sudden martial law
The military, which has a long history of interfering in Thai politics, stepped into the fray Tuesday with its sudden declaration of martial law -- a move it carried out without giving any warning to the acting prime minister.
Thailand martial law: A cheat sheet to get you up to speed
"They took this action unilaterally," an aide to the prime minister told CNN, describing the situation as "half a coup d'etat."
Military officials denied that their intervention, which has deepened uncertainty over the country's future, was a coup. But human rights activists warned that the imposition of martial law is a major step away from democracy and lacks safeguards.
Human Rights Watch said the declaration of martial law "threatens the human rights of all Thais."
The law includes restrictions on where protesters can gather, what TV and radio broadcasters can air and social media posts,
The interim prime minister said he is glad the army chief is trying to find an end to the crisis.
"The government also wants to see (a) solution ... under democratic means," his statement said, "including to find the new elected government the soonest to solve the problems for the people of Thailand."
How the chaos unfolded
Thailand has been hit by bouts of political unrest over the past decade.
The current wave of turmoil was triggered in November by Yingluck's botched attempt to pass an amnesty bill that would have allowed the return of her brother Thaksin Shinawatra, another former prime minister who lives in exile and polarizes opinions in Thailand. Thaksin was deposed by a military coup in 2006.
Groups opposed to the government seized on the amnesty bill furor and began large-scale protests in central areas of Bangkok.
In an attempt to defuse tensions, Yingluck called an early election. But the Democrat Party boycotted the February election, and Yingluck's opponents blocked voting in enough districts to prevent a valid outcome.
The leaders of the anti-government protesters say elections -- which the Shinawatra family's populist Pheu Thai party is likely to win -- aren't the way to resolve the crisis. They say they want the establishment of an unelected "people's council" that would oversee political changes.
Yingluck, who first took office in 2011, stayed on after the disrupted election as a caretaker prime minister. But the Constitutional Court forced her from office two weeks ago, finding her guilty of violating the constitution over the appointments of top security officials.
Yingluck has denied breaking the law.
CNN's Jethro Mullen and Catherine E. Shoichet contributed to this report.