The full House of Representatives voted 268-151 Friday to grant the waiver to bypass the federal law that bars someone from serving in the post within seven years of retirement from active military duty.
Mattis retired from active duty in 2013.
The Senate and committees in both chambers approved the waiver earlier this week. It now must be signed by the president, Obama or Trump. If it reaches the current president's desk, press secretary Josh Earnest said Obama will sign it.
Congress created the mandate with the National Security Act of 1947 -- believing civilian leadership in the Pentagon ensures the fewest question marks for policy-making, which has the potential to be unpopular with active duty members of the armed forces.
Only one other waiver has ever been granted by Congress, for active U.S. Army Gen. George C. Marshall when he became defense secretary in 1950.
Now, all that's left for Mattis to be confirmed is a full Senate vote, which is expected as early as next week.