As migrants continue to arrive in their thousands despite border limits, Hungary has found itself in an increasingly difficult position.
On Monday, the ruling Fidesz party garnered 151 votes for the legislative amendment.
Under the amended law, soldiers involved with refugee management have been granted authorities similar to those of the police.
They are now allowed to demand identification, to detain people, to search the persons, packages, and vehicles of suspects and to participate in monitoring border traffic in a way that includes coercive measures.
Hungarian Prime Minister Viktor Orban told parliament that the military was currently needed on the Slovenian and Croatian borders.
The EU has criticized Hungary for its response to the migrant crisis, but Budapest claims that it fails to get any help from its neighbors and Western countries.