By Julien Toyer

MADRID (Reuters) - A former treasurer of Spain's ruling party, at the heart of a corruption scandal that has hurt Prime Minister Mariano Rajoy, was ordered to surrender his passport on Monday while judges investigate millions of euros he deposited in Swiss banks.

Luis Barcenas is accused of using his position to take bribes, evade taxes by hiding the proceeds in Switzerland and launder money through shell companies, charges that carry prison sentences of up to six years and fines.

The long-running High Court investigation of Barcenas and a graft case involving the son-in-law of Spain's king have enraged Spaniards at a time when deep recession has pushed unemployment to 26 percent and the government has slashed public spending.

After three hours of questioning Barcenas in a closed-door court hearing, High Court examining judge Pablo Ruz ordered steps be taken to restrict the suspect's movements as there was "a serious risk" he might attempt to flee.

He said he had gathered evidence on the three charges of tax fraud, bribery and money laundering and that his investigation could come to an end soon.

In Spain's legal system, lengthy pre-trial investigations are carried out by examining magistrates such as Ruz. It is not clear when a trial could start.

Ruz banned Barcenas from leaving Spain, seized his passport and ordered him to report to a court twice a month.

Barcenas, 55, an avid mountaineer who once scaled Everest, went skiing in Canada two weeks ago, according to media reports. Some of these reports said the police suspected he also used the ski trip to move funds he holds there.

Barcenas's lawyer declined to comment on those reports.

The judge also confirmed he was seeking additional information on accounts and companies related to Barcenas in Switzerland, Argentina and the United States.

TROUBLE AT THE TOP

Barcenas left the center-right People's Party (PP) in 2009 after he was charged with taking money from companies that overcharged PP mayors to put on events, such as campaign rallies, then shared the extra profit with the politicians.

Public interest in the case had largely evaporated until January, when Ruz's investigation revealed Barcenas had Swiss bank accounts once worth as much as 22 million euros ($30 million).

The High Court judge also found that Barcenas applied last year for a tax amnesty, instigated by Rajoy to try to boost revenue, to bring millions of euros in off-shore investments back to Spain.

Then, El Pais newspaper published extracts from what it said were secret PP account books that Barcenas kept for almost 20 years, showing cash donations from construction magnates that were distributed to Rajoy and other party leaders.

Barcenas has denied any wrongdoing and says the purported ledgers are forgeries.

However, a police report that is part of Ruz's evidence and that was seen by Reuters, showed that in December Barcenas made a notarized statement saying he had records of years of donations made to the party as well the recipients.

Barcenas says the money in the Swiss accounts is from legitimate business activities, but Ruz's investigation has cast doubt on that defense, according to court documents which have been seen by Reuters.

Rajoy has denied any wrongdoing, either personal or by the party. He has pledged an external audit of PP accounts and put years of his own personal tax declarations on the official website of the office of the prime minister.

The Barcenas scandal has soured a public mood already bitter over joblessness, cuts to education, health spending and public sector wages, and the 40 billion euros in public funds spent on rescuing failed banks.

Tens of thousands of homeowners have defaulted on their mortgages and been evicted from their homes.

A small group of protesters joined dozens of reporters in front of the court building in central Madrid after Barcenas entered for the closed-door hearing.

"They are lying to us, and worse than that, scorning us... Enough is enough, we need some accountability," said Ana, 59, a civil servant from Madrid who declined to give her last name.

(Writing by Fiona Ortiz; Editing by Jon Hemming)