  We give a Lagrangian formulation for the theory of Rastall of gravitation.
After proposing a Lagrangian density that reproduces the equations of motion
postulated by Rastall, we study the cosmological consequences and fit the
parameters using recent data from Hubble function $H(z).$ According to two
model selection criteria, one based on corrected Akaike Information Criterion
(AICc) and another on Bayesian Information Criterion (BIC), known to penalize
models with a greater number of parameters, particularly BIC, we obtain some
competitive models relative do $\Lambda CDM.$ In one of these models the
cosmological constant is interpreted as having origin in the creation of matter
due to time dependent gravitational field, as opposed to the origin in the
vacuum energy.
