Vice President Mike Pence has sworn in the first two confirmed members of the new US cabinet, James Mattis as defense secretary and John Kelly as homeland security secretary.

The two retired Marine generals were approved by the Senate on Friday, just hours after President Donald Trump took the oath of office.

Republicans pushed for fast approval of Mattis to ensure the post would not be empty even for a brief amount of time after Trump's swearing-in.

He will replace Ash Carter, who has been former President Barack Obama's defense secretary since February 2015.

Congress had to pave the way for Mattis to serve. Lawmakers last week passed legislation that Trump signed granting Mattis an exception from the law barring former service members who have been out of uniform for less than seven years from holding the job.

Mattis retired from the Marine Corps in 2013.

Kelly will be in charge of overseeing Trump's pledge to crack down on illegal immigration.

If Trump keeps his campaign promises, Kelly's agency will be responsible for strengthening the screening of immigrants permitted to enter the US. His department also will be charged with finding additional resources to locate and deport people living in the country illegally.