A hinge mechanism in which two housings are respectively connected to a first rotation shaft and a second rotation shaft that are arranged perpendicular to each other and the housing are arbitrarily openable about either one of the shafts is provided. In the hinge mechanism 1, at an end of a rotation shaft holding section (4) of a hinge housing (1), an end of an opening and closing shaft holding section (5) is integrated together in a state of being perpendicular to each other, the rotation shaft holding section (4) being formed in it a tubular shaft hole for supporting a rotation shaft section (3), and the opening and closing shaft holding section (5) being formed in it a tubular shaft hole for supporting an opening and closing shaft section (2), and the hinge housing (1) is substantially L-shaped as a whole. When the opening and closing shaft (2) is rotated, an opening and closing limiting outer peripheral surface enters an escape recess to cause a restraining end section to be restrained by the opening and closing limiting outer peripheral surface, and as a result, rotation of the rotation shaft section (3) is restrained. When the rotation shaft section (3) is rotated, a rotation limiting outer peripheral surface of the rotation shaft section (3) enters a portion of a restraining end surface to cause rotation of the opening and closing shaft (2) to be restrained.