I finally found a solution. Like Timothy Truckle wrote, I used the export/import plugin, BUT before that, I had to rename the mail files, otherwise the import would only show empty directories.
First, find where kmail stores your messages (there may be more than one place if you have several accounts):
$ ls -1d ~/.local/share/local-mail ~/.local/share/*/local-mail
~/.local/share/0/local-mail
~/.local/share/1/local-mail
~/.local/share/local-mail
Then in EACH of those directories, do ALL of the following:
# This performs a backup
zip -r ~/mail.backup.zip ~/.local/share/local-mail
cd ~/.local/share/local-mail
# This renames the files so that the import will identify them properly
find -type f -exec mv -v '{}' '{}.eml' \;
Now you could stop here and go import the directories in Thunderbird, but you will end up with a lot of empty directories and misnamed directories, such as .Friends.directory or .Family/cur, so a little scripting can clean things up first.
# Remove empty directories
find -type d -exec rmdir -v '{}' \;
# Move the files up from cur/, tmp/ and new/
find -type d -name cur -exec bash -c 'for dir; do mv -v "$dir"/* "$(dirname "$dir")/"; done' bash {} +
find -type d -name tmp -exec bash -c 'for dir; do mv -v "$dir"/* "$(dirname "$dir")/"; done' bash {} +
find -type d -name new -exec bash -c 'for dir; do mv -v "$dir"/* "$(dirname "$dir")/"; done' bash {} +
find -type d -exec rmdir -v '{}' \;
find -type d -iregex "\..*\.directory"
# Now move ../.something.directory into ../something (which may not exist)
find -depth -type d -iregex "\..*\.directory" -exec bash -c 'for dir; do A=$(echo $dir | sed -e "s#\(.*\)\.\([^/]*\).directory#\1\2#"); mv -v "$dir"/* "$A/" ; done' bash {} +
# if there are still .something.directory, just rename them manually to 'something' (this line won't do it automagically):
find -type d -iregex "\..*\.directory"
Finally, in Thunderbird, create a directory IMPORT under Local Folders, select it (don't forget as right-click is not enough!), right-click on it, [ImportExportTools], [Import all messages from Directory, also its subdirectories], and let it work for a while.
I could write a script to do all of the above, but now that I've finally managed to move my mail, I'm just fed up with it.