my jeeps making a scraping & sort of rattling noise;now goes into 4x4 by itself on 1991 Jeep Cherokee

It started making a scraping kind of noise which I thought sounded like my brakes; then a rattling noise that got progressively worse. Now the part time idiot light comes on, so I assume it's going into 4x4 by itself. Is it the transfer case and how difficult (and expensive) to fix?

Asked by for the 1991 Jeep Cherokee