The Supreme Court on Thursday rejected diversity plans in two major school districts that take race into account in assigning students but left the door open for using race in limited circumstances.

The decision in cases affecting schools in Louisville, Ky., and Seattle could imperil similar plans in hundreds of districts nationwide, and it further restricts how public school systems may attain racial diversity.