In this paper, we derive a 'Hamiltonian formalism' for a wideclass of mechanical systems, that includes, as particular cases,classical Hamiltonian systems, nonholonomic systems, some classes ofservomechanisms... This construction strongly relies on thegeometry characterizing the different systems. The main result ofthis paper is to show how the general construction of theHamiltonian symplectic formalism in classical mechanics remainsessentially unchanged starting from the more general framework ofalgebroids. Algebroids are, roughly speaking, vector bundlesequipped with a bilinear bracket of sections and two vector bundlemorphisms (the anchors maps) satisfying aLeibniz-type property. The bilinear bracket is not, in general,skew-symmetric and it does not satisfy, in general, the Jacobiidentity. Since skew-symmetry is related with preservation of theHamiltonian, our Hamiltonian framework also covers some examples ofdissipative systems. On the other hand, since the Jacobi identity isrelated with the preservation of the associated linear Poissonstructure, then our formalism also admits a Hamiltonian descriptionfor systems which do not preserve this Poisson structure, likenonholonomic systems. Some examples of interestare considered: gradient extension of dynamical systems,nonholonomic mechanics and generalized nonholonomic mechanics, showing the applicability of our theory and constructing the corresponding Hamiltonian formalism.