Quarterback Trey Lance was demoted and then traded in the same week.

The San Francisco 49ers agreed Friday to trade Lance to the Dallas Cowboys, a person with direct knowledge of the deal told USA TODAY Sports on the condition of anonymity because the deal was not yet official. San Francisco is receiving a 2024 fourth-round pick for the quarterback, who is set to serve as a backup and developmental option behind starter Dak Prescott.

The trade marks an unceremonious end in San Francisco for Lance, the No. 3 overall pick in the 2021 NFL draft for whom the 49ers surrendered three first-round picks and a third-rounder in a move up the board.

"We took a shot and it didn't work out. We own that. We take accountability for it," 49ers GM John Lynch said on the NFL Network broadcast during the Niners' preseason game Friday night, even though the trade was still not yet official.

He started his remarks by calling Lance "such a wonderful young man" and added that Lance's story "is still very much unwritten."

PLAY TO WIN $10K: USA TODAY's Pro Football Survivor Pool is free to enter. Sign up now!

"I'm excited for Trey. Dallas stepped up and really wanted him. They came after him, and I think it's going to be a great landing spot for him," Lynch said.

Lance played in eight total games in the last two seasons, including four starts. Lance was the 49ers' starting quarterback going into 2022, but his year ended abruptly when he suffered a season-ending ankle injury in Week 2.

Once Lance was ruled out for the year and backup Jimmy Garoppolo was also sidelined, seventh-round rookie Brock Purdy emerged as San Francisco’s quarterback of the present and future, leading the club all the way to the NFC championship game.

On Wednesday, the 49ers announced that Sam Darnold would serve as Purdy's backup this season, leaving the team to evaluate its options with Lance.

“It’s been a tough road for him, because the times he has got an opportunity, he ended up getting hurt and missing that window,” 49ers coach Kyle Shanahan told KNBR. “We’ll always try to do right for Trey. If there’s a better situation that his heart’s in, we’re going to make sure not to hurt him in that way."

Lance leaves the Bay Area with just 797 passing yards, five TDs and three interceptions in eight career games.

Follow USA TODAY Sports' Tyler Dragon on Twitter @TheTylerDragon.

Disclaimer: The copyright of this article belongs to the original author. Reposting this article is solely for the purpose of information dissemination and does not constitute any investment advice. If there is any infringement, please contact us immediately. We will make corrections or deletions as necessary. Thank you.