Dante's Divine Comedy, written in the years 1308-1320, is a long narrative poem in which the poet is also a protagonist in the story. The story also includes many real characters, such as Virgil and many Florentines who had been involved in the struggle between the Guelphs and the Ghibellines. However, it is obviously not an autobiographical work, since Dante's journey through hell, purgatory and paradise is not a real event.
This leads me to the question whether the Divine Comedy is the earliest work of literature in which the author is also a protagonist in the story. This should not be confused with works in which the protagonist is the narrator but not the historical author; narrator and author are two different concepts. (I am also excluding philosophical dialogues from this question, otherwise Plato's dialogues might be a valid answer.)
citation-needed
;-)