The UK and Scottish governments have been accused of "passing the buck" over decisions not to hold a public inquiry into undercover policing in Scotland.
It came during a judicial review of the UK government's refusal to extend an inquiry into undercover policing in England and Wales to Scotland.
The Court of Session review also covers the Scottish government's decision not to set up a separate inquiry.
The case has been brought by environmental campaigner Tilly Gifford.
She says she was spied on by undercover police units who infiltrated activist groups, some forming long-term relationships with campaigners and even fathering children.
Ms Gifford, a member of the Plane Stupid campaign group, says she was targeted in Scotland in 2009 by officers who wanted to recruit her as an informant.
She was arrested during a protest at Aberdeen Airport and says police wanted her to feed them intelligence on the protest group in exchange for cash.
Aidan O'Neill QC, representing Ms Gifford, told the court: "Everyone is passing the buck on this one".
He went on to claim the UK government was "deaf" to concerns about activities in Scotland, adding: "Cross the border, at Berwick or Gretna, and suddenly 'we're not interested, we don't care, it's nothing to do with us'.
"It's slightly odd that it should be carving out a bit of the UK when it's clear that these forces were operating throughout the UK."
He also criticised the reasons given by the Scottish government not to hold inquiry as "insufficient".
Mr O'Neill said: "There are questions of concern about not only how English and Welsh police units were operating in Scotland but also how undercover operations were carried out by Scottish legacy police forces.
"There's more than a whiff of greater things going on."
The Undercover Policing Inquiry, under retired judge Sir John Mitting, is currently examining the conduct of undercover Metropolitan Police officers in England and Wales.
UK ministers have said it is "not possible" to extend it to Scotland, despite claims of officers also spying north of the border.
Scottish ministers said they were "extremely disappointed" by this.
But in February, then Justice Secretary Michael Matheson rejected calls for a wider probe following a report on undercover policing in Scotland which showed "no evidence of any systemic failings".
Advocate Andrew Webster, for the UK government, urged judge Lady Carmichael to reject Ms Gifford's petition.
He said the action was effectively "time barred" because it had been raised 15 months after the terms of reference for the Mitting inquiry - then under Sir Christopher Pitchford - were set in 2015.
This was despite Ms Gifford's contact with undercover police having taken place "well before" in 2009.
Solicitor Advocate Christine O'Neill, who was representing the Scottish government, said it had not been demonstrated a public inquiry was necessary in this case.
The hearing will conclude on Friday, with a ruling delivered by judge Lady Carmichael later in the year.
Speaking ahead of the hearing, Ms Gifford told the BBC's Good Morning Scotland programme: "There is no recourse to truth and justice in Scotland. There is no inquiry here and this is why we have to bring this case to court.
"I was targeted in Scotland. I will never find out who these men were that followed me, why I was targeted or who commissioned this to happen.
"But I am just one example.
"Behind me there are miners who were on strike in 1984/85, trade unionists, peace campaigners in Scotland. And all the women who were in long-term relationships with these officers in Scotland.
"These people need answers to what happened in Scotland and who commissioned these things to happen."
The Undercover Policing Inquiry in England and Wales relates to units set up to use undercover police officers to infiltrate activist groups.
Mostly instigated by the Metropolitan Police, the officers worked in long-term operations within political groups on the far left and right, and animal rights groups.
Often, they formed intimate relationships with female members, in some cases fathering children - a practice that has been widely condemned.
Ms Gifford said: "These are really serious abuses of human rights. These officers stole the identities of dead children, deceived women into long-term intimate relationships, some of them fathered children and disappeared out of these women's lives when they got a promotion to go and train more police officers to do the same thing.
"It's revolting the level of institutional sexism and human rights abuses - how can we move forward and have any proper safeguards in place and protect ourselves and the general public if we don't understand what happened?"