Story highlights The Senate approved the waiver easily on Thursday

Mattis had a low-key confirmation hearing

Washington (CNN) Donald Trump's nominee for defense secretary cleared an important legal hurdle on Friday as the House voted largely along party lines to grant him a special exemption from a key law that had been standing in his way.

The House voted 268-151 in favor of giving Ret. Gen. James Mattis the needed waiver. The Senate voted overwhelmingly in favor of doing so on Thursday, after Mattis' confirmation hearing.

President Barack Obama is expected to sign the waiver soon, a move that helps clear the way for installing one of the top members of his successor's national security team.

Senate Republicans are aiming to vote on Mattis' confirmation to lead the Pentagon on January 20, the day President-elect Donald Trump is sworn in as president.

Law dictates that any military official must wait seven years from leaving the service before serving as defense secretary, a civilian position. Mattis retired in 2013, meaning he could not be secretary of defense unless Congress passed a special exception.

Read More