Aaron Ramsey scored both goals in the victory, finding the net on either side of the halftime interval to ensure Ryan Giggs' men will join already-qualified Croatia in advancing out of Group E.
Wales and Hungary both entered Tuesday's clash knowing a victory would secure progression to the 24-team competition. Slovakia also had a chance of sneaking in, but its 2-0 triumph over Azerbaijan was ultimately rendered moot by the result in Cardiff.
The Welsh, who made an unexpected run to the Euro 2016 semifinals, will be appearing in just their third major tournament.
All 20 automatic qualifying spots for the quadrennial tournament are now sealed. A playoff in March will determine the occupants of the four berths still up for grabs.