The appointment of Agrawal, a 10-year veteran of Twitter, signaled a tacit endorsement by the board of a strategy the company previously laid out to double its annual revenue by 2023, even if investors were not so sure.
Twitter shares surged nearly 10% after the announcement and closed down 2.7%.
Dorsey, who co-founded Twitter in 2006, is leaving after overseeing the launch of new ways to create content through newsletters or audio conversations while simultaneously serving as CEO of his payments processing company Square Inc.
He also navigated the tumultuous years of U.S. President Donald Trump's administration before banning the Republican from the platform after the Jan. 6 attack on the U.S. Capitol.
The CEO change is effective immediately and Dorsey will remain on the board until his term expires at the 2022 annual shareholder meeting, the company said.
In an email to employees on Monday, Dorsey said he chose to step down due to the strength of Agrawal's leadership, the naming of Salesforce Chief Operating Officer Bret Taylor as the new chairman of the board and his confidence in the "ambition and potential" of Twitter's employees.
"I'm really sad ... yet really happy," he wrote. "There aren't many companies that get to this level," adding that his move to step down "was my decision and I own it."
"We recently updated our strategy to hit ambitious goals, and I believe that strategy to be bold and right," Agrawal said in an email to employees. "But our critical challenge is how we work to execute against it and deliver results."
Over the past year, Twitter has fought to end years-long criticism that it has been slow to introduce new features for its 211 million daily users and was losing ground to social media rivals like Instagram and TikTok.
Under Dorsey's leadership, Twitter acquired email newsletter service Revue and launched Spaces, a feature that lets users host or listen to live audio conversations.
The company also rolled out advertising improvements to help brands find Twitter users likely to be interested in their product, a key component of the company's goal to double annual revenue by 2023.
However, shares of Twitter have slumped in recent months, adding pressure on Dorsey to end his unusual arrangement of being CEO of two public companies.
In early 2020, Dorsey faced calls from Elliott Management Corp to step down, after the hedge fund argued that he was paying too little attention to Twitter while also running Square Inc.
Dorsey fended off the pressure by giving Elliott and its ally, buyout firm Silver Lake Partners, seats on Twitter's board.
In a joint statement issued after the announcement, Elliott Managing Partner Jesse Cohn and Marc Steinberg, a senior portfolio manager, endorsed the baton passing. "We are confident that they (Agrawal and Taylor) are the right leaders for Twitter at this pivotal moment for the company."
Dorsey will now focus on leading Square and other pursuits such as philanthropy, a source familiar with the matter told Reuters.
The company's board has been preparing for Dorsey's departure since last year, the source said.
The appointment of Agrawal as Twitter's new CEO suggests the company has picked engineering as its top priority.
Agrawal has helped lead Twitter's work on incorporating cryptocurrencies and blockchain technologies into the company and also pursue its long-term ambition to rebuild how social media companies operate.
He has been a key figure in Bluesky, a Twitter-funded organization that is seeking to build a "decentralized" common standard for social media companies. Such a standard would allow different social platforms to operate on the same technology and let users post content across the services, for instance.
Bluesky's work will likely take years to complete, Dorsey has said.
For now, investors are hoping Agrawal's technical prowess will help Twitter's advertising "engine" grow, said analysts from Baird Equity Research in a note on Monday.
Twitter earns the majority of its revenue from selling advertising on its website and app. But its ability to offer highly targeted advertising to drive product sales has lagged far behind larger rival Facebook , advertising experts have said.
The company previously said it sought to grow its highly targeted advertising segment to 50% of its business -- it currently constitutes just 15%.
As investors digested the news, the market likely realized Agrawal's "mountain to scale" to reach the company's revenue targets and felt "some disappointment that a Twitter outsider hasn't been brought in to offer fresh ideas," said Susannah Streeter, an analyst at Hargreaves Lansdown.
(Reporting by Greg Roumeliotis in New York, Subrat Patnaik in Bengaluru and Sheila Dang in Dallas; Editing by Andrea Ricci and Lisa Shumaker)
By Greg Roumeliotis and Sheila Dang