Scotland's top health official branded NHS 24 a "dysfunctional organisation" after MSPs heard how the cost of a new IT and call handling system spiralled over budget by more than £40m.

The cost of the telephone health service's Future Programme rose by 55% from an outline business case cost of £75.8m to £117.4m, Holyrood's Public Audit Committee heard.

NHS chief executive Paul Gray told the committee he is "very sorry indeed" for the overspend - which he said could rise to £49.2m.

Spending watchdog Audit Scotland found the increase was due to changes in the contract specification and costs associated with the delay in implementing the system.

The committee heard that staff within NHS 24 knew of the potentially costly contractual flaws two years before the matter was escalated to senior management in January 2014.

Mr Gray said: "As the accountable officer for the health budget, I both understand and accept the committee's expressed anger and frustration at the very substantial delays and cost increases associated with the NHS 24 Future Programme, and I am very sorry indeed about this."

He acknowledged the potential overspend could rise to £49.2m "depending on what the ultimate implementation is".

He added: "I'm aware that the knowledge of the deficiencies of the contract was with staff in NHS 24 sometime before the chief executive and the chair were told.

"The chair and the chief executive did not know until January 2014."

Conservative MSP Mary Scanlon said: "Are you not concerned that not only did you not know that they were running towards a £50m overspend, the director of finance did not know, the chief executive did not know, and a member of staff employed a leading legal company to try and negotiate this contract that you were unaware of, the officers (and the) director of finance, were unaware of?"

Mr Gray said: "It causes me grave concern. An organisation in which a member of staff knows something of that significance and does not escalate it immediately to the board is a dysfunctional organisation.

"It would be my concern, therefore, to ensure that no organisation for which I am responsible behaves in such a way that a member of staff feels that they cannot escalate an issue of that significance to the board."

Committee convener Paul Martin asked Mr Gray if he feels he has "let down the Scottish Government" with the information provided on multimillion-pound overspend at a time when frontline health services are under strain.

Mr Gray said: "I've been the accountable officer for two years and two months, but that doesn't alter the fact that ultimately I am responsible for the total sum.

"The decisions that were taken in relation to what got us here were taken before I was the accountable officer, but nevertheless I am the accountable officer now and I am accepting responsibility."