Brazil, who were without star forward Neymar due to an ankle injury, rarely troubled Switzerland's goal in a dull first half but showed more threat in the second period. Vinicius Jr. thought he had put Brazil ahead on 66 minutes when he ran through on goal and slotted past goalkeeper Yann Sommer, but it was disallowed for an offside in the build-up.
However, it was Casemiro who proved to be the hero for the five-time world champions as he popped up with a superb half-volley on 83 minutes to secure a narrow win and a place in the round of 16.
Monday's victory leaves Brazil in a solid position to finish as leaders in Group F with six points after two games -- three ahead second-place Switzerland.
It was hard to believe the match at Doha's Stadium 974 was being played on the Arabian Peninsula, for it had every setting of a home game for the Brazilians -- from the thunderous roars accompanying every fancy move to the rhythmic beat drummed out throughout.
The Brazilians had only won three of their nine matchups with Switzerland in total, with four drawn and two losses, and Monday's clash looked to be heading for another stalemate before Casemiro's moment of magic.
With Brazil increasingly desperate, half-time substitute Rodrygo played a first time ball to Casemiro who struck it with the outside of his foot and it glided past Sommer, the Swiss goalkeeper watching in horror as it bulged the inside of his goal.
While Rodrygo provided the assist, Casemiro and Brazil owe a debt of gratitude to Vinicius Jr. for the goal -- Brazil's newest superstar had drawn three increasingly desperate defenders onto him which created space for the goal.
Winded by a cruel moment of Brazilian brilliance, the Swiss slumped and the match could well have ended two or 3-0, but that would have been unduly harsh on the Europeans who, for the most part, blunted their opponents.
The Swiss, though, can take heart from their performance and a win against Serbia in their final group match will send them through along with Brazil.