RIO DE JANEIRO — The judge was stumped.

He had ordered a pair of identical twins to take DNA tests in a paternity case in the central Brazilian state of Goiás. Both came back positive.

Neither man would say who fathered the girl at issue. Her mother had turned to the courts seeking financial support for the child, who was born after a casual fling. The woman said she could not say for sure which of the two men she had slept with.

So Judge Filipe Luis Peruca opted to punish both twins.

In a ruling made public on Monday, he chided the men for acting in “bad faith” and ordered that each pay child support for the girl, who is now 9.

The mother, whose name is redacted in court documents, initially sought financial help from just one of the twins, whose identities were also not disclosed.