Import password hash
I figured it out by myself now. In case someone runs into the same problem:
Updating the database directly avoids the problem of rehashing:

$query = \Drupal::database()-&gt;update('users_field_data')-&gt;fields([
    'pass' =&gt;$prefixed_password_hash,
])-&gt;condition('uid',$user-&gt;id());

$query-&gt;execute();