The Supreme Court on Wednesday limited the amount of damages that those who possess child pornography must pay victims, throwing out a $3.4 million award that went to a woman whose childhood rape has been widely seen on the Internet.

The court voted 5 to 4 that those convicted of possessing child pornography must pay restitution to victims. But it said the amount of damages paid must be proximate to the harm that a specific offender has caused.

The case before the court involves a a Texas man, Doyle Randall Paroline, who pleaded guilty to possessing 300 images of child pornography, including two of an 8- or 9-year-old girl identified in court documents as “Amy Unknown.” An appeals court had said Paroline was liable for all of the $3.4 million in damages that Amy, now an adult, was owed for psychological damage and lost income after she discovered the ­images.

All nine Supreme Court justices indicated that the law Congress passed requiring restitution to victims of child pornography was flawed, and several called for a rewrite that would provide more precision and guidance.

Justice Anthony M. Kennedy, who wrote the majority opinion, noted that his approach “is not without difficulties.”

“But courts can only do their best to apply the statute as written in a workable manner, faithful to the competing principles at stake: that victims should be compensated and that defendants should be held to account for the impact of their conduct on those victims,” Kennedy wrote.

At the same time, he said, courts must assure that defendants are liable only “for the consequences and gravity of their own conduct, not the conduct of others.”

Kennedy said there were three options: Give Amy nothing, because it is impossible to decide how Paroline’s possession of two images affected her; make Paroline liable for all of the damages, even though it is clear that his actions alone did not cause all of Amy’s problems; or take the middle ground.

Kennedy was joined by Justices Ruth Bader Ginsburg, Stephen G. Breyer, Samuel A. Alito Jr. and Elena Kagan.

“Regretfully” dissenting, Chief Justice John G. Roberts Jr. said a proper reading of the law would mean Paroline should pay nothing. “The statute as written allows no recovery,” Roberts wrote in a dissent joined by Justices Antonin Scalia and Clarence Thomas. “We ought to say so, and give Congress a chance to fix it.”

Justice Sonia Sotomayor also dissented, but in the opposite direction. She said that her reading of the law, which states that courts “shall direct the defendant to pay the victim . . . the full amount of the victim’s losses,” means that Paroline and every other defendant should be liable for all of Amy’s loss, which is what the U.S. Court of Appeals for the 5th Circuit had ruled. Under that scenario, Amy would receive no more than the total $3.4 million, but it might be easier to collect if one of the defendants was wealthy enough to pay it all.

Kennedy said paying nothing should not be an option. “Every viewing of child pornography is a repetition of the victim’s abuse,” he wrote. “One reason to make restitution mandatory for crimes like this is to impress upon offenders that their conduct produces concrete and devastating harms for real, identifiable victims.”

But Kennedy said that making each defendant liable for the total amount would be so “severe” as to raise constitutional questions.

Instead, Kennedy said, there should be “reasonable and circumscribed” restitution that “comports with the defendant’s relative role.”

That will be difficult for judges, he acknowledged, because “this cannot be a precise mathematical inquiry.”

But he said that district courts should consider several factors. Among them: the number of other defendants who have paid restitution, the number of future offenders likely to be caught, and whether the defendant reproduced or distributed images of the victim.

Amy was raped by an uncle when she was 8 and 9, and the events were recorded. The uncle received a lengthy prison term and paid about $6,000 in restitution.

When she was 17, she learned that the images were widely available online. Her attorney, Paul G. Cassell, estimates more than 70,000 people have seen them.

Courts have estimated damages in lost income and counseling costs at nearly $3.4 million, but they have been collected in a piecemeal manner. Cassell said it has taken 41 / 2 years to collect $1.75 million from 182 defendants ($1.2 million came from one man).

In a statement posted on The Volokh Conspiracy blog, which is hosted by The Washington Post, Cassell said he was disappointed by the ruling. He is a regular contributor to the blog.

“As Amy has recognized, the Supreme Court’s split-the-difference ruling promises her that she will receive full restitution ‘someday,’ ” Cassell wrote. “I just wonder how far in the future that someday will be.”

He quoted Amy: “The Supreme Court said we should keep going back to the district courts over and over again but that’s what I have been doing for almost six years now,” she said in a statement. “It’s crazy that people keep committing this crime year after year and now victims like me have to keep reliving it year after year.”

The case is Paroline v. United States.