The Italian glamour team, the oldest and most successful in the sport, have made a poor start to the season with two fourth places for Spaniard Fernando Alonso, the team's best results in three races so far.
Ferrari have not won a driver's World championship since Kimi Raikkonen in 2007, although they were constructors' champions in 2008. At the most recent race in Bahrain, Alonso and his Finnish team mate were ninth and 10th.
"There are particular moments in all of our professional lives where you need the courage to take difficult and very painful decisions," Domenicali, who had been principal since January 2008, said in a Ferrari statement.
"It is time for a significant change. As the boss, I take responsibility, as I have always done, for our current situation.
"This decision has been taken with the aim of doing something to shake things up and for the good of this group of people that I feel very close to," added the 48-year-old Italian.
Mattiacci will take overall charge of the Gestione Sportiva - the carmaker's sporting activities including the Formula One team that has competed in every championship since 1950 - with immediate effect.
Ferrari had hoped to make a strong start to Formula One's new V6 turbo hybrid era this season but they and Renault - who power champions Red Bull - have been eclipsed by rivals Mercedes.
The German manufacturer has won all three races with a power unit that looks for more competitive and reliable than others.
Domenicali, who has been with Ferrari for 23 years in various roles, replaced Jean Todt as team principal when the Frenchman took on a more senior management role at the Maranello headquarters.
Todt, who presided over a golden era at Ferrari when Michael Schumacher won five titles in a row between 2000 and 2004, is now head of the sport's governing International Automobile Federation (FIA).
Domenicali brought a friendlier, more open and less combative atmosphere to the team in a new era of greater collaboration with rivals at a time when global financial troubles were threatening the sport.
He was one of the youngest and most approachable principals but that landscape has changed considerably with Mercedes, Lotus and McLaren all revamping their management structures since the end of 2013.
Mercedes and McLaren have scrapped the formal role of principal, with Ron Dennis in overall charge of the latter following the exit of Martin Whitmarsh.
Domenicali thanked Ferrari president Luca di Montezemolo, who has been involved in Formula One since the 1970s, and the fans with the regret "that we have been unable to harvest what we worked so hard to sow in recent years."
Montezemolo, who has strongly criticised the sport's new rules, thanked Domenicali for his contribution and "the great sense of responsibility he has shown even today in putting Ferrari's interests ahead of his own".
The next race is the Chinese Grand Prix on April 20.
Image: Stefano Domenicali
Photograph: Mark Thompson/Getty Images
Ferrari set to be stoked by fire and ice this season
Hope to see F1 racers and not 'taxi drivers'
F1 pit lane tales: Red Bull appeal is first test of F1's new era
Hamilton wins Bahrain thriller for Mercedes
Ecclestone says F1 has agreed to two new teams