Scottish government lawyers had "reservations" about its court battle with Alex Salmond more than two months before it conceded the case.
The judicial review was examining whether the government's handling of harassment complaints against the former first minister was legal.
Mr Salmond has said the government was told in October 2018 that it was likely to lose the case.
But it did not admit it had acted unlawfully until January 2019.
The government ultimately had to pay Mr Salmond's legal fees of more than £500,000 on top of its own costs.
Deputy First Minister John Swinney has now admitted that concerns were raised ahead of the government admitting defeat.
But he insisted there were "good public policy arguments and reasonable grounds" to continue contesting the case for a further two months.
There have been claims that continuing to contest the case after being given legal advice that it was unlikely to succeed would be a waste of public money and potentially a breach of the ministerial code.
The government is to release key papers - including external legal advice - to the Holyrood inquiry committee that is investigating the saga, with Mr Swinney saying the unusual move was to "counter false claims being made by some".
The Scottish Conservatives said they would press ahead with a vote of no confidence in the deputy first minister, saying he was "releasing only the evidence he wants us to see".
There has been a long-running row over the legal advice given to the Scottish government after Mr Salmond launched judicial review proceedings in 2018 over the way internal harassment complaints against him had been investigated.
The government admitted in January 2019 that its approach had been unlawful, because its investigating officer had had prior contact with the two complainers - in breach of a newly-designed procedure.
Mr Salmond had claimed that ministers were given legal advice on 31 October 2018 which "indicated that on the balance of probability, the government was going to lose the judicial review".
He said that "if the case was continued in the knowledge of the first minister against that legal advice, that would be a breach of the ministerial code".
The Holyrood committee investigating the government's botched handling of the complaints has been pushing to see the full legal advice for some time, and MSPs have twice voted to say it should be handed over.
On Monday, Mr Swinney confirmed that key papers would be handed over - after it became clear that all opposition parties were set to back a motion of no confidence in his position.
He confirmed that concerns had been raised about the issue which ultimately collapsed the government's case, but insisted there were other reasons to fight on.
The committee has previously been shown a memo summarising legal advice, which said external counsel had threatened to resign on 28 December 2018 and that Permanent Secretary Leslie Evans was told the next day that "the only sensible and defensible position is to concede the petition".
In a letter to the committee published on Tuesday, Mr Swinney said: "The documents confirm that, whilst reservations were raised about the judicial review following the identification of the issue of prior contact with the complainers in late October, there were good public policy arguments and reasonable grounds for the government to continue to defend the judicial review and to seek a determination from the court on the matters raised, until the events of late December 2018."
Mr Swinney also told the committee that the documents being released should be with them by Tuesday afternoon.
However the Scottish Conservatives said they would not be withdrawing their motion of no confidence until the committee was satisfied that all of the advice had been handed over.
Leader Douglas Ross said: "Recklessly continuing with the judicial review when it was doomed would clearly be a breach of the ministerial code. The public deserve to know exactly what mistakes were made.
"John Swinney is not getting away with releasing only the evidence he wants us to see. We will press ahead with the vote of no confidence until all the legal advice is published."
In his letter, the deputy first minister said that the release of the material meant "the Scottish government will have responded to all of the committee's requests for specific documents within our legal and other obligations".
He said he hoped that it would "assist the committee in fulfilling its remit and address some of the allegations that have been raised, without evidence, in the past few days".
On Tuesday morning, Lord Advocate James Wolffe - the government's top legal advisor and head of the prosecution service - mounted a defence of the role of the Crown Office in the various rows over Mr Salmond's submissions.
Mr Wolffe told the inquiry committee that "any suggestion from any quarter" that the prosecution service had not acted independently "would be wholly without foundation".
He said the parliament had been "right" to redact one of Mr Salmond's written statements after the Crown Office raised concerns that "certain parts of the submission were liable to be a breach of a court order".
He added: "Mr Salmond has stated that the Crown has tied his hands in respect of the use of information that he holds - it is the law, not the Crown, that stays his hands".
The Lord Advocate also denied that there was a conflict between his post combining the roles of government minister and independent prosecutor, saying: "My fundamental responsibility is to the rule of law and the administration of justice - that fundamental principle underpins all of the functions I have."