diff --git a/typo3/sysext/core/Classes/Database/RelationHandler.php b/typo3/sysext/core/Classes/Database/RelationHandler.php
index f3a713bf8acc54b548e67920e2ccd300da260d37..8eac1fb70effed49128893eeabc091cf09ade9d8 100644
--- a/typo3/sysext/core/Classes/Database/RelationHandler.php
+++ b/typo3/sysext/core/Classes/Database/RelationHandler.php
@@ -409,7 +409,12 @@ class RelationHandler
                         ? strrev(trim($parts[1]))
                         : ($this->secondTable && $theID < 0 ? $this->secondTable : $this->firstTable);
                     // If the ID is not blank and the table name is among the names in the inputted tableList
-                    if (((string)$theID != '' && $theID) && $theTable && isset($this->tableArray[$theTable])) {
+                    if (
+                        (string)$theID != ''
+                        // allow the default language '0' for the special languages configuration
+                        && ($theID || ($configuration['special'] ?? null) === 'languages')
+                        && $theTable && isset($this->tableArray[$theTable])
+                    ) {
                         // Get ID as the right value:
                         $theID = $this->secondTable ? abs((int)$theID) : (int)$theID;
                         // Register ID/table name in internal arrays:
diff --git a/typo3/sysext/core/Classes/Tests/FunctionalTestCase.php b/typo3/sysext/core/Classes/Tests/FunctionalTestCase.php
index bd04e12315defc9a8568b3245cb5b364dbd84b9f..8030cfd06c5521cc97be01b0ad0b42eac6db977d 100644
--- a/typo3/sysext/core/Classes/Tests/FunctionalTestCase.php
+++ b/typo3/sysext/core/Classes/Tests/FunctionalTestCase.php
@@ -269,6 +269,14 @@ abstract class FunctionalTestCase extends BaseTestCase
         return $GLOBALS['TYPO3_DB'];
     }
 
+    /**
+     * @return ConnectionPool
+     */
+    protected function getConnectionPool()
+    {
+        return GeneralUtility::makeInstance(ConnectionPool::class);
+    }
+
     /**
      * Initialize backend user
      *
diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/SpecialLanguagesTest.php b/typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/SpecialLanguagesTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..bdafec0c039d3ac18755aecb7128d1b420fcabd0
--- /dev/null
+++ b/typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/SpecialLanguagesTest.php
@@ -0,0 +1,66 @@
+<?php
+declare (strict_types = 1);
+namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase;
+
+/**
+ * Testing behavior of TCA field configuration 'special' => 'languages'
+ */
+class SpecialLanguagesTest extends AbstractDataHandlerActionTestCase
+{
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->backendUser->workspace = 0;
+    }
+
+    /**
+     * @param string $value
+     * @param string $expected
+     *
+     * @test
+     * @dataProvider allowedLanguagesAreAssignedToBackendUserGroupDataProvider
+     */
+    public function allowedLanguagesAreAssignedToBackendUserGroup($value, $expected)
+    {
+        $this->actionService->createNewRecord('be_groups', 0, [
+            'title' => 'Testing Group',
+            'allowed_languages' => $value,
+        ]);
+
+        $statement = $this->getConnectionPool()
+            ->getQueryBuilderForTable('be_groups')
+            ->select('allowed_languages')
+            ->from('be_groups')
+            ->where('uid=1')
+            ->execute();
+        $this->assertEquals($expected, $statement->fetchColumn(0));
+    }
+
+    /**
+     * @return array
+     */
+    public function allowedLanguagesAreAssignedToBackendUserGroupDataProvider()
+    {
+        return [
+            'valid languages' => ['1,2', '1,2'],
+            'default language' => ['0', '0'],
+            'empty value' => ['', ''],
+            'invalid integer' => ['not-an-integer', ''],
+        ];
+    }
+}