Turkish Prime Minister Recep Tayyip Erdogan appeared to have succeeded in asserting a ban on the Twitter networking site in the run-up to critical local polls.
Mr Erdogan fears the vote could be influenced by what he calls fake online tapes accusing him of corruption
An Ankara court upheld an appeal against the ban from the bar association but a source in Mr Erdogan's office said the telecoms authority had 30 days to implement or appeal the decision.
The regulator did not immediately comment.
The ruling, despite a separate court challenge by Twitter describing the blocking order as "disproportionate and illegal", would allow the ban to stay in place until after the polls, an attempt to impede widely expected further releases of tapes.
Sunday's polls have assumed huge significance as a test for Mr Erdogan as he fights graft accusations he says were fabricated by a former ally, US-based cleric Fethullah Gulen.
Recent weeks have seen almost daily anonymous internet release of tapes of telephone conversations suggesting Mr Erdogan was involved in corruption. The prime minister calls them "montages".
Turkey's telecoms authority (TIB) blocked access to Twitter on Friday after Mr Erdogan said he would "root out" the network.
The move provoked public outrage and drew international condemnation, with Mr Erdogan's critics seeing it as the latest in a series of authoritarian steps to crush a graft scandal which has grown into the biggest challenge of his 11-year rule.
Tech-savvy Turks have quickly found workarounds, with internet analysts reporting a surge in tweets since the ban was imposed, but the issue has become a tug-of-war between Mr Erdogan's administration and the San Francisco-based microblogging site.
Twitter said it had suspended content related to two of three court orders given as the legal basis for the ban because they violated its own rules.
But it was challenging a third order to remove an account accusing an ex-minister of graft.
"With all announced bases for the access ban addressed, there are no legal grounds for the blocking of our service in Turkey," it said in an official blog posting.
"We expect the government to restore access to Twitter immediately so that its citizens can continue an open online dialogue ahead of the elections," the statement said.
Twitter's legal challenge was also expected to be delayed by Turkish court procedures.
Deputy Prime Minister Bulent Arinc, seen as a more conciliatory figure at the top of the ruling AK Party than Mr Erdogan, urged the telecoms authority to respect the Ankara court's decision.
"We abide by the court rulings, that's what the constitution orders. We may not like them, but we abide by them. If this decision is genuine ... then what TIB needs to do after this is obvious," Mr Arinc told reporters in Hatay in televised comments.
Yesterday, Mr Erdogan accused Twitter of "threatening national security" and has repeatedly defended the ban during rallies in the run-up to the municipal elections on Sunday, his party's first test at the ballot box since the corruption scandal erupted in December and since street protests last summer.
"Our problem is not Twitter itself but its approach ... The court ruling was conveyed to Twitter. It does not listen to it," Mr Erdogan said in a TV interview late last night about the original decision to block access.
"You are threatening the national security of my country," he said in a voice strained by weeks of campaign rallies.
The controversy over the ban has added to an already febrile atmosphere ahead of Sunday's elections, with some rival candidates even warning of armed provocateurs and possible assassination attempts during the polls.
Interior Minister Efkan Ala called on candidates to behave responsibly, saying during a visit to the eastern city of Ezurum that "every measure" had been taken to secure the polls.
His AK Party is expected to continue to dominate the electoral map after the election and is aiming for around the 40% share of the vote it achieved at the last local polls in2009, although close races are expected in Ankara and Istanbul.
Telecoms regulators have said the Twitter blockage was based on four court orders and was imposed after complaints from citizens that the microblogging site was violating privacy.
Mr Erdogan's declaration last week that he would root out Twitter, and the subsequent attempt to block it in Turkey, triggered denunciations from European officials and the US government, which spoke of "21st century book burning".