In 1806 , Joseph Bonaparte was given military command of Naples , and shortly afterward was made king by Napoleon I , to be replaced after two years by his sister 's husband , Joachim Murat , when Joseph was made king of Spain in August 1808 , soon after the French invasion . In 1806 , Joseph was given military command of Naples , and shortly afterward was made king by Napoleon , to be replaced after two years by his sister 's husband , Joachim Murat , when Joseph was made king of Spain in August 1808 , soon after the French invasion .