WASHINGTON - The Supreme Court raised constitutional doubts Monday about the lifelong monitoring of sex offenders and other criminals with the use of GPS devices.

In a unanimous decision, the justices ruled for a North Carolina man and said this monitoring is a search under the Fourth Amendment that must be justified as reasonable based on all the circumstances.

Since 2005, 40 states have adopted laws that provide for GPS monitoring of ex-offenders. California was said to have the first and largest monitoring program. The court was told that 9,300 sex offenders in California were being tracked, along with some gang members.

Monday's decision stops well short of striking down such monitoring, but it opens the door for ex-offenders to argue for limits.

A North Carolina lawyer who appealed the case praised the court for putting some restrictions on monitoring.

"This is a significant case. North Carolina and other states have basically taken the position that they can strap a GPS monitoring device to whomever they choose. The court here is basically saying, no, any such search must be reasonable. In many cases, that's going to be impossible to demonstrate," said Luke Everett, a lawyer in Durham.

After a 20-minute hearing in 2013, Torrey Grady was ordered to enter a GPS monitoring program that would require him to wear an ankle bracelet "for the remainder of his natural life." He was not on probation, but he had been convicted of a sex offense when he was a teenager in 1997 and of taking indecent liberties with a child in 2006.

North Carolina's law calls for monitoring of repeat offenders. He appealed the order, arguing it was an unreasonable search under the Fourth Amendment. A North Carolina court ruled that monitoring was not a search at all, and the North Carolina Supreme Court refused to hear his claim.

The Supreme Court issued a summary reversal Monday in Grady v. North Carolina and said the monitoring was governed by the Fourth Amendment. "A state conducts a search when it attaches a device to a person's body, without consent, for the purpose of tracking that individual's movement," the justices said.

But they note the Fourth Amendment forbids only "unreasonable searches," and they sent the case back to North Carolina for judges there to consider whether the lifelong monitoring of Grady was reasonable.