  We consider the Palatini formulation of $f(R,T)$ gravity theory, in which a
nonminimal coupling between the Ricci scalar and the trace of the
energy-momentum tensor is introduced, by considering the metric and the affine
connection as independent field variables. The field equations and the
equations of motion for massive test particles are derived, and we show that
the independent connection can be expressed as the Levi-Civita connection of an
auxiliary, energy-momentum trace dependent metric, related to the physical
metric by a conformal transformation. Similarly to the metric case, the field
equations impose the non-conservation of the energy-momentum tensor. We obtain
the explicit form of the equations of motion for massive test particles in the
case of a perfect fluid, and the expression of the extra-force, which is
identical to the one obtained in the metric case. The thermodynamic
interpretation of the theory is also briefly discussed. We investigate in
detail the cosmological implications of the theory, and we obtain the
generalized Friedmann equations of the $f(R,T)$ gravity in the Palatini
formulation. Cosmological models with Lagrangians of the type $f=R-\alpha
^2/R+g(T)$ and $f=R+\alpha ^2R^2+g(T)$ are investigated. These models lead to
evolution equations whose solutions describe accelerating Universes at late
times.
