* Government tightening control over judiciary
* Gul says his warnings helped prevent constitution violations
* Opposition to challenge law at Constitutional Court (Adds quotes, details)
By Humeyra Pamuk
ANKARA, Feb 26 (Reuters) - Turkish President Abdullah Gul on Wednesday approved a law boosting government control over the appointment of judges and prosecutors, even though he deferred some elements in the legislation to the Constitutional Court.
The law, along with a regulation tightening control of the Internet already approved by Gul, is seen by Prime Minister Tayyip Erdogan's critics as part of a backlash against a corruption inquiry shaking his government.
Erdogan has also accused his enemies on Tuesday of hacking encrypted state communications to fake a phone conversation suggesting he warned his son to hide large sums of money before police raids as part of the inquiry.
The law will give the government more say in the naming of judges and prosecutors, a role currently fulfilled by the High Council of Judges and Prosecutors (HSYK).
Critics say the move contravenes the basic principle of the separation of powers enshrined in the constitution.
Erdogan has hit back at the corruption investigation, which began in December with the arrest of sons of ministers and businessmen close to the prime minister, by reassigning thousands of police and hundreds of judges and prosecutors in moves viewed as targeting what he says is a "parallel state".
Erdogan says his former ally, Turkish U.S.-based Islamic cleric Fethullah Gulen, has built that "parallel state" through his movement's influence in the judiciary and police and that the law will counter that sway.
"The HSYK has been perceived by the government as the headquarters of this so-called parallel structure, so with this law the government is dissolving that centre," the president of the Association of Judges and Prosecutors Murat Arslan said.
"It is a major blow to the independence of the judiciary. We were not a defender of the old HSYK law but this one is even worse."
Turkey's National Security Council said it held a three hour meeting on Wednesday in which the "structures and activities that threaten the peace of our nation and our national security" were discussed, in an apparent reference to so the alleged parallel state.
In passing the bill, Gul said he warned the justice minister about 15 points that he regarded as anti-constitutional.
Following his intervention, some articles giving extensive authority to the justice minister, such as the power to expel audit judges and inspectors from the HSYK were removed.
Under the revisions, the board's general assembly, rather than the minister, will have the authority to take disciplinary action against board members, Gul's statement said.
"After the correction of these clear violations, I found it more appropriate for the law to be published and for the Constitutional Court to assess the other articles of the law which are subject to pro and con arguments," he said.
The main opposition CHP party is expected to file a challenge to the law at the Constitutional Court, seeking its annulment.
But even if the court rules to overturn some articles in the law, the government will have enough time to make changes that will tighten its grip over the HSYK, Arslan said.
The law will come into effect once it is published in the Official Gazette and all personnel of the HSYK, excluding the 20 elected members, will then loses their jobs.
The unelected staff amounts to around 1,000 people, including its secretary-general, inspectors, audit judges and administrative staff, whose positions will then be filled by the justice minister, according to the Hurriyet daily.
Rights groups and the opposition had urged Gul, a more conciliatory figure than Erdogan, to veto the law, just as they did with the Internet legislation.
"The post of presidency unfortunately has become a part of the attempts to cover up the filth, corruption and bribery in Turkey," the main opposition CHP party's spokesman Haluk Koc told reporters. (Reporting by Tulay Karadeniz and Humeyra Pamuk; Writing by Daren Butler; Editing by Alison Williams)