Hungarian Prime Minister Ferenc Gyurcsany has won a confidence vote in parliament amid a continuing row over his admission that he lied to voters.
Gyurcsany apologised for a "lack of courage"
The prime minister secured the backing of 207 MPs, with 165 voting against.
Earlier on Friday he apologised for his conduct, after admitting lying to voters in April's election campaign.
But the political uncertainty looked set to continue, with as many as 50,000 people gathering in front of parliament to demand that Mr Gyurcsany quit.
The demonstrators, including families with children, many waving the Hungarian flag, were summoned by opposition leader Viktor Orban, who has vowed to unseat the prime minister.
Farmers also blocked roads in parts of the countryside in protest at the government's agricultural policies.
Mr Gyurcsany began a day of debate in parliament by expressing what amounted to a mea culpa, says the BBC's Nick Thorpe in Budapest.
He apologised for not facing up to economic realities at the general election.
He and his government campaigned on tax cuts but promptly put taxes up after being voted in, in an effort to reduce a budget deficit that had ballooned to 10% - the biggest in the EU.
Hungarian farmers protested by blocking roads outside Budapest
"We avoided facing up to reality, we lacked courage and we tried to bypass the most honest, simplest answers. If an apology is needed for anything, then it is for this. I apologise," the prime minister said.
But Mr Gyurcsany vowed to stick to his austerity programme.
Then he went on the offensive, sharply rebuking the main conservative opposition party, Fidesz, and its leader, Mr Orban, for what he called threats and "blackmail", and ridiculing the opposition's economic programme.
Mr Orban said on Thursday he would use all legitimate democratic means to oust the prime minister.
"The Socialists... have entrapped the country and want to sacrifice the country for a lying politician," Mr Orban said. "All constitutional, democratic and parliamentary means must be used to oust Ferenc Gyurcsany."