Let R be a Borel equivalence relation with countable equivalence classes, on the standard Borel space
(
X
,
A
,
μ
)
(X,\mathcal {A},\mu )
. Let
σ
\sigma
be a 2-cohomology class on R with values in the torus
T
\mathbb {T}
. We construct a factor von Neumann algebra
M
(
R
,
σ
)
{\mathbf {M}}(R,\sigma )
, generalizing the group-measure space construction of Murray and von Neumann [1] and previous generalizations by W. Krieger [1] and G. Zeller-Meier [1]. Very roughly,
M
(
R
,
σ
)
{\mathbf {M}}(R,\sigma )
is a sort of twisted matrix algebra whose elements are matrices
(
a
x
,
y
)
({a_{x,y}})
, where
(
x
,
y
)
∈
R
(x,y) \in R
. The main result, Theorem 1, is the axiomatization of such factors; any factor M with a regular MASA subalgebra A, and possessing a conditional expectation from M onto A, and isomorphic to
M
(
R
,
σ
)
{\mathbf {M}}(R,\sigma )
in such a manner that A becomes the “diagonal matrices";
(
R
,
σ
)
(R,\sigma )
is uniquely determined by M and A. A number of results are proved, linking invariants and automorphisms of the system (M, A) with those of
(
R
,
σ
)
(R,\sigma )
. These generalize results of Singer [1] and of Connes [1]. Finally, several results are given which contain fragmentary information about what happens with a single M but two different subalgebras
A
1
,
A
2
{{\mathbf {A}}_1},{{\mathbf {A}}_2}
.