The feature you're referring to is called invasion multiplayer.
The game that introduced this seems to be Demon's Souls from 2009 (lauded for introducing the core characteristics of the Souls game series):
Online multiplayer allows both player cooperation and world invasions featuring player versus player combat.
source
It is worth nothing that this gameplay mechanic was being developed two years earlier by Arkane, but the game which had it implemented was never released:
In 2007 Arkane Studios began creating a game called The Crossing [..]. The team behind the game wanted to include a mechanic they called “cross-player”, in which host players would have some enemy characters in their game controlled by other human players and give players a reprieve from the usual multiplayer experience.
Unfortunately, the game was never released due to publisher and financial issues, but the cross-player mechanic was definitely a predecessor to invasion mechanics in future titles.
source
Arkane did pick up some core elements of The Crossing for Deathloop.
Games that offer invasion multiplayer are:
Title |
Year |
Type |
Elden Ring |
2022 |
⨁⨺ |
Sniper Elite 5: France |
2022 |
⨁⨺ |
Deathloop |
2021 |
⨺ |
Demon's Souls |
2020 |
⨁⨺ |
Dark Souls: Remastered |
2018 |
⨁⨺ |
Watch_Dogs 2 |
2016 |
⨁⨺ |
Dark Souls III |
2016 |
⨁⨺ |
Bloodborne |
2015 |
⨁⨺ |
Metal Gear Solid V: The Phantom Pain |
2015 |
⨺ |
Watch_Dogs |
2014 |
⨁⨺ |
Dark Souls II |
2014 |
⨁⨺ |
Dark Souls: Prepare to Die Edition |
2012 |
⨁⨺ |
Journey |
2012 |
⨁ |
Dark Souls |
2011 |
⨁⨺ |
Demon's Souls |
2009 |
⨁⨺ |
⨁: helpful ⨺: hostile
Sources: 1, 2, 3, 4, 5