The former chief constable of South Yorkshire Police described the force's relationship with the BBC over a search of Sir Cliff Richard's home as a "shotgun wedding".
David Crompton said he did not want publicity for the search but he agreed the corporation should be told the date and time of it to avoid compromising the investigation.
Giving evidence at the High Court on Thursday he said: "We were in a difficult position.
"I considered it to be of paramount importance that we were able to complete an unhindered and untainted investigation and one might say the relationship with the BBC became a shotgun wedding."
The 77-year-old entertainer is claiming "substantial" damages for what he says was a "very serious invasion" of his privacy when the raid on his home was broadcast in 2014.
The coverage included footage taken from a helicopter flown above the singer's home on a private estate in Sunningdale, Berkshire.
The BBC contends there was a "legitimate public interest" in its coverage and is vigorously defending the case.
Mr Crompton denied a proposition put to him by Gavin Millar QC that the evidence was "quite clear" the police force wanted publicity of its investigation into Sir Cliff.
He said those within the force who knew about it had taken care not to refer to the investigation in writing, to avoid any possible leaks.
However he said "all that changed" following a conversation between reporter Dan Johnson and the force's head of communications, Carrie Goodwin, in which Mr Johnson indicated he was aware Sir Cliff was being investigated.
He said: "This (publicity) was specifically not wanted, however that conversation was a game changer.
"What I wanted was that we should be able to complete the investigation without it being compromised.
"I didn't want the television coverage, that was not the ideal, however the situation we were in was that this was, in effect, the price to pay."
Sir Cliff was accused of molesting a teenager at Sheffield United's Bramall Lane during a rally led by the Evangelical preacher Billy Graham in the 1980s.
But no charges were brought against the singer after an investigation lasting almost two years.
South Yorkshire Police has already paid £400,000 in damages to the singer.
Lawyers are due to give their closing arguments in the case next week.