Short answer. No. A judge cannot buy property or rights that are in litigation before the court where he exercises his functions. The Civil Code lists judges among the persons who cannot acquire such property by purchase, whether directly or through someone acting for them.
What the law says
Justices, judges, prosecuting attorneys, clerks of superior and inferior courts, and other officers and employees connected with the administration of justice, the property and rights in litigation or levied upon an execution before the court within whose jurisdiction or territory they exercise their respective functions
Civil Code, Article 1491 — Persons Who Cannot Buy. Read the full provision →
A specific list of people who cannot buy
Article 1491 names several categories of people who cannot acquire by purchase, even at a public or judicial auction, either in person or through the mediation of another. Guardians, agents, executors and administrators, and certain public officers all appear on it. Judges are on the list too, grouped with justices, prosecuting attorneys, clerks of court and other officers connected with the administration of justice. The phrase about buying through the mediation of another matters: the judge cannot get around the rule by having a relative, a dummy, or a friend make the purchase in their place. The disqualification follows the office.
Which property is caught
The ban is not a rule that a judge may never own real estate. It is tied to a particular relationship between the property and the court. What a judge cannot buy is the property and rights in litigation or levied upon an execution before the court within whose jurisdiction or territory they exercise their respective functions. In other words, the thing must be the subject of a case, or under execution, in that judge's own court. Property that has nothing to do with any case before the judge is not covered by this particular prohibition at all.
Why the rule exists
The prohibition protects public confidence in the courts. A judge who could quietly buy the very property being fought over in the courtroom would have a personal stake in how the case comes out, and no litigant could trust the result. The same logic explains why the article expressly extends the ban to the act of acquiring by assignment and, in its own words, applies the disqualification to lawyers over property that is the object of litigation they take part in. The concern is the conflict between private gain and public duty, not the mechanics of the sale.
What happens if the rule is broken
A purchase made in the teeth of this prohibition is not the kind of contract the law is willing to protect, and it can be challenged. Because the interest at stake is public and not merely private, the defect is treated as fundamental rather than a technicality the parties can simply agree to overlook. If you are dealing with property tied to a pending case and a court officer appears as the buyer, that is a situation to have examined closely. A lawyer can assess whether the sale falls within the prohibition and what can be done about it.