The African Union wants the ICC to drop the charges against Uhuru Kenyatta
Kenyan MPs have approved a motion to leave the International Criminal Court (ICC) following an emergency debate.
A bill to this effect is expected to be introduced in the next 30 days, after opposition MPs boycotted the vote.
The ICC has charged President Uhuru Kenyatta and Deputy President William Ruto with crimes against humanity, which they both deny. Mr Ruto's trial is due to start in The Hague next week.
The ICC said the cases will continue, even if Kenya pulls out.
The charges against both Mr Kenyatta and Mr Ruto stem from violence that broke out after disputed elections in 2007, in which more than 1,000 people were killed and 600,000 forced from their homes.
They were on opposite sides during the 2007 election but formed an alliance for elections in March this year, and analysts say the ICC prosecutions bolstered their campaign as they portrayed it as foreign interference in Kenya's domestic affairs.
Kenya's parliament is dominated by the pair's Jubilee coalition.
The motion, tabled by majority leader Adan Duale, said Mr Kenyatta and Mr Ruto were "lawfully elected" and the government should take steps to "immediately" withdraw from the Rome Statute, which established the ICC.
The US had refused to sign the Rome Statute to protect its citizens and soldiers from potential politically motivated prosecutions, Mr Duale told MPs.
"Let us protect our citizens. Let us defend the sovereignty of the nation of Kenya," he is quoted as saying.
MPs from the opposition Coalition for Reforms and Democracy (Cord), led by former Prime Minister Raila Odinga, walked out of the debate, calling the motion "capricious" and "ill-considered".
Kenya's withdrawal would not bring "honour to the nation and dignity to our leaders", Cord said in a statement.
"Kenya cannot exist outside the realm of international law in all situations," it said.
ICC spokesman Fadi El Abdallah told the BBC's Newsday programme that Kenya's withdrawal would have no bearing on the cases against the two men.
"A withdrawal has an effect only for the future and never for the past," he said.
If Mr Kenyatta and Mr Ruto failed to co-operate, ICC judges "may decide to issue arrest warrants against these accused", Mr Abdallah added.
Amnesty International said the parliamentary motion was the latest in a series of "disturbing initiatives to undermine the work of the ICC in Kenya and across the continent".
"Amnesty International calls on each and every parliamentarian to stand against impunity and reject this proposal," said Netsanet Belay, the group's Africa programme director, in a statement.
The BBC's Gabriel Gatehouse reports from the capital, Nairobi, that any decision to withdraw from the ICC would take about a year to come into effect.
Nevertheless, a vote to withdraw would certainly cause consternation in the international community and might embolden other countries, especially in Africa, to follow suit, he says.
Both Mr Kenyatta and Mr Ruto have repeatedly called for the cases against them to be dropped, saying the charges are politically motivated.
The ICC has refused and says it pursues justice impartially.
In May, the African Union accused the ICC of "hunting" Africans because of their race.
The ICC strongly denies this, saying it is fighting for the rights of the African victims of atrocities.
The ICC was set up in 2002 to deal with genocide, crimes against humanity, war crimes and the crime of aggression.
The court has been ratified by 121 countries, including 34 in Africa.