Ms Pelosi - the most senior US politician to visit in 25 years - departed on Wednesday after meeting leaders in the capital Taipei.
But her visit, as part of a wider Asian tour, sparked fury in Beijing after she ignored its warnings not to travel to the island.
Taiwan is self-ruled - but China sees it as a breakaway province that will eventually unite with it, reports BBC.
In a statement issued on Wednesday, China's Foreign Minister Wang Yi said "those who play with fire will not come to a good end, and those who offend China will be punished".
"The United States is violating China's sovereignty under the guise of so-called democracy," he added.
The US walks a diplomatic tightrope with its Taiwan policy.
On the one hand, it abides by the "One China" policy, which recognises only one Chinese government, giving it formal ties with Beijing and not Taiwan.
But on the other, it also maintains a "robust unofficial" relationship with the island, which includes selling weapons for Taiwan to defend itself.
As speaker of the US House of Representatives, Ms Pelosi is second in line to the US presidency, behind Vice-President Kamala Harris.
Taiwan puts the ball firmly in Xi Jinping's court
In response to the trip, China announced what it called "necessary and just" military drills in seas around 10 miles (16 kilometres) from Taiwan.
The exercises - which will begin on Thursday and last for five days - will take place in some of the world's busiest waterways and will include "long-range live ammunition shooting".
A US official told the Reuters news agency on Wednesday that Beijing may seek to use the visit to ramp up tensions. China's defence ministry spokesman Sun Li-fang admitted that some of the exercises may breach Taiwan's territorial waters.
President Tsai Ing-wen said Taiwan is facing "deliberately heightened military threats", adding that it "would not back down and that Taiwan will do whatever it takes to strengthen its self-defence capabilities".
Taiwan's port authorities have asked ships to find alternative routes to avoid the drills, and Transport Minister Wang Kwo-tsai said Taipei was negotiating with neighbouring Japan and the Philippines to find alternative aviation routes.
It follows days of escalating tensions in which Chinese warplanes already ventured as far as the median line, the unofficial divide separating China and Taiwan in the waters between them.
During a meeting with Ms Tsai, Ms Pelosi praised Taiwan as "inspiration to all freedom-loving people" .
She also insisted that America's "decision to preserve democracy here in Taiwan remains iron-clad".
"Forty three years ago, America made a promise to always stand with Taiwan... today our delegation came to Taiwan to make it unequivocally clear we will not abandon our commitment to Taiwan," Ms Pelosi added.
The 82-year-old had earlier met Taiwan Deputy Speaker of Parliament Tsai Chi-Chang.
While the top Democrat's visit has been welcomed in Taiwan, it has somewhat split opinion in the US.
The White House has been opposed the trip, and President Joe Biden had said the military assessed it as "not a good idea".
And some commentators speculated that the visit could even push China to supply arms to Russia for use in Ukraine - something it has so far refused to do.
But she has received support from some perhaps unexpected quarters, with 26 Republican senators writing a letter in support of the visit.
The letter, whose signatories included Senate minority leader Mitch McConnell, said that "for decades, members of the United States Congress, including previous Speakers of the House, have travelled to Taiwan".
The trip, it added, was "consistent with the United States' One China policy to which we are committed".