The law was passed by the Polish parliament and is expected to be implemented immediately.
The wall, which will be equipped with motion sensors, is estimated to cost about 350m euros and will take months to complete.
As the Polish Minister of Defense admitted, the inspiration came from Hungary, which built a wall on its border with Serbia, during the 2015 immigration crisis.
Poland is facing increased flows of refugees and migrants arriving at its border from Belarus, mainly aiming to enter Germany.
The barbed wire that was placed, as well as the increased patrols did not bring satisfactory results.
Poland has declared a 400-kilometer state of emergency on its border with Belarus.