ABSTRACT. We consider a Hamiltonian setup (M, ω, H, L, Γ, P), where (M, ω) is a symplectic manifold, L is a distribution of Lagrangian subspaces in M, P a Lagrangian submanifold of M, H is a smooth time dependent Hamiltonian function on M and Γ : [a, b] → M is an integral curve of the Hamiltonian flow H starting at P. We do not require any convexity property of the Hamiltonian function H. Under the assumption that Γ(b) is not P-focal it is introduced the Maslov index i maslov (Γ) of Γ given in terms of the first relative homology group of the Lagrangian Grassmannian; under generic circumstances i maslov (Γ) is computed as a sort of algebraic count of the P-focal points along Γ. We prove the following version of the Index Theorem: under suitable hypotheses, the Morse index of the Lagrangian action functional restricted to suitable variations of Γ is equal to the sum of i maslov (Γ) and a convexity term of the Hamiltonian H relative to the submanifold P. When the result is applied to the case of the cotangent bundle M = T M * of a semi-Riemannian manifold (M, g) and to the geodesic Hamiltonian H(q, p) = 1 2 g −1 (p, p), we obtain a semi-Riemannian version of the celebrated Morse Index Theorem for geodesics with variable endpoints in Riemannian geometry.