The answer is very field specific. In many departments all that matters is your research. Does your dissertation and publications fit the department's vision for what it means to do research in field X, regardless of the field of your degree.
However, in some fields it is really hard to get in the door without a degree in that field. The example I am thinking of is Mathematics. Theoretical biologists, economists, social scientists etc. with degrees in the field of application tend not to end up in math departments even if nearly 100% of their research is proving theorems. This isn't to say it can't be done, but it seems as though it is much easier to move in the opposite direction from a math department to a science department. For example if you work on pure problems in probability but your degree is in economics, it is hard to get a job in a math department.
Disclaimer 1: it is unclear how much of this is due to selection bias by the job candidate vs. discrimination in the math department against people without math degrees.
Disclaimer 2: this is based on anecdotal evidence and faculty listings on department websites that show where mathematicians from science departments end up after their degree. I have not sat on a hiring committee.