Former chief financial officer of Anglo Irish Bank Matt Moran has begun giving evidence at the Dublin Circuit Criminal Court.
Mr Moran is giving evidence in the trial of the bank's former chairman, Seán FitzPatrick, and two former directors, Pat Whelan and William McAteer, who deny 16 charges of giving illegal loans to 16 people to buy shares in the bank.
Mr Whelan also denies seven charges of being involved in fraudulently altering a document.
The court heard that Mr Moran has been granted immunity from prosecution in relation to the matters with which this trial is concerned and in respect of other matters in which prosecutions may be taken.
The court heard the immunity was granted following discussions between Mr Moran's legal representatives and the Director of Public Prosecutions.
Mr Moran told the court he was chief financial officer in Anglo in 2007 and 2008 and reported directly to Mr McAteer.
He said he himself was a shareholder in Anglo Irish Bank and also held shares in other Irish banks.
He said in the summer of 2007 he sold all of his shares in Irish banks except in Anglo because he was requested not to by Anglo's then chief executive, David Drumm.
Mr Moran said because of his position in the bank at, his position in relation to the shares would have had to be reported to the market.
He said the bank was trying multiple initiatives to deal with Seán Quinn's stake in Anglo shares through Contracts for Difference.
None were successful.
Mr Moran said in July 2008, he was told by Mr McAteer that the bank's executives had decided to approach ten clients of the bank to ask them to buy shares.
On 9 July, Mr Moran said Mr Drumm came into his office looking for Mr McAteer. Mr Drumm said he had spoken to the regulator about the proposed transaction and had got his approval. He said Mr Drumm made a thumbs up gesture.
Mr Moran will continue his evidence tomorrow.
The court was earlier told that the Financial Regulator was "excited" by a proposed plan by Anglo Irish Bank to lend money to ten customers to buy Anglo shares.
The plan was part of a plan to unwind Mr Quinn's 28% interest in the bank, which he held through high-risk Contracts for Difference - in effect a bet on Anglo shares.
The former head of Anglo in the UK, Declan Quilligan, said he got a call from Mr Drumm on 8 July 2008.
He said Mr Drumm told him he was meeting the Financial Regulator the next day to go through a proposal under which the bank would lend money to a number of "high net worth individuals" with a view to taking some of Mr Quinn's shares out of the market.
The court was shown details of an email exchange between Mr Quilligan and Mr Drumm the next day.
Mr Drumm sent an email saying: "Regulator squared".
Mr Quilligan replied: "Excellent! Hope he was grateful!"
Mr Drumm replied: "Excited I would say. I think he is lying awake at night like the rest of us."
Mr Quilligan said his reply probably reflected the benefit to the regulator of what was being done.
He said it was hoped the deal would stabilise Anglo's funding and avoid a calamitous situation not just for Anglo.
He said if Anglo had been brought down, overseas fund managers would not have been hanging around in other Irish banks to see if their money was safe.
Mr Quilligan said a deal to get the bank's clients to buy shares was always the bank's least preferred option.
He said he always understood the bank would have to lend money to the customers as they would not have had that kind of cash available to them.
He could not say if it was explicitly said at a bank board meeting in June 2008.
Mr Quilligan said the bank ran out of options.
Doing nothing, he said, was not an option.
If they had done nothing, he said, the Quinn position would have been unwound in an uncontrolled way and the risk to the bank and the Irish banking system would have been catastrophic.
Mr Quilligan said with the benefit of hindsight he wished that he had had it all in writing.
He said he wished that everyone involved in the transaction had signed off that the reason why this happened was for the good of the Irish banking system.
He said after the bank was nationalised it was being said the bank acted alone, without consulting anyone and without taking advice.
He said six months earlier everyone had been comfortable and aware of the deal and that it was for the good of the banking system, but six months later it was being held out as an example of poor governance in the bank.