diff --git a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php
index 7bedf79a5c..5d447bf40d 100644
--- a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php
+++ b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php
@@ -126,6 +126,7 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
         '#derivative_plugin_id' => $block->getDerivativeId(),
         '#in_preview' => $event->inPreview(),
         '#weight' => $event->getComponent()->getWeight(),
+        '#attributes' => $content['#attributes'] ?? [],
       ];
 
       // Place the $content returned by the block plugin into a 'content' child
@@ -140,7 +141,6 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
       // move these properties from $content and merge them into the top-level
       // element.
       if (isset($content['#attributes'])) {
-        $build['#attributes'] = $content['#attributes'];
         unset($content['#attributes']);
       }
       // Hide contextual links for inline blocks until the UX issues surrounding
diff --git a/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php b/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php
index 9d797038db..8196cf2161 100644
--- a/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php
+++ b/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php
@@ -118,6 +118,7 @@ public function testOnBuildRender($refinable_dependent_access) {
       '#configuration' => [],
       '#plugin_id' => 'block_plugin_id',
       '#base_plugin_id' => 'block_plugin_id',
+      '#attributes' => [],
       '#derivative_plugin_id' => NULL,
       'content' => $block_content,
       '#in_preview' => FALSE,
@@ -196,6 +197,7 @@ public function testOnBuildRenderWithoutPreviewFallbackString($refinable_depende
       '#base_plugin_id' => 'block_plugin_id',
       '#derivative_plugin_id' => NULL,
       'content' => $block_content,
+      '#attributes' => [],
       '#in_preview' => FALSE,
     ];
 
diff --git a/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php
index a149ff8467..41ae9655b8 100644
--- a/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php
+++ b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php
@@ -116,6 +116,7 @@ public function testToRenderArray() {
         'max-age' => -1,
       ],
       '#in_preview' => FALSE,
+      '#attributes' => [],
     ];
 
     $block = $this->prophesize(BlockPluginInterface::class)->willImplement(PreviewFallbackInterface::class);
@@ -256,6 +257,7 @@ public function testContextAwareBlock() {
         'tags' => [],
         'max-age' => -1,
       ],
+      '#attributes' => [],
       '#in_preview' => FALSE,
     ];
 
