Violent protests in Sao Paulo were quickly pushed to one side as drama switched to the football pitch.
Croatia took a shock lead when Marcelo scored an own goal in the 11th minute.
Neymar pulled Brazil level after 30 minutes, but Croatia were left in fury when Japanese referee Yuichi Nishimura pointed to the spot in the second half after Fred backed into Croatian defender Dejean Lovren and fell.
Barcelona golden boy Neymar, who was also booked, converted the penalty to put Brazil ahead and Chelsea midfielder Oscar scored a brilliant individual goal to seal the crucial victory in Group A.
The five-time winners start the tournament as overwhelming favourites, seeking to heal decades of hurt after the humiliation of losing the final to Uruguay on home soil in 1950. But they made a nervous start in the Corinthians Arena.
The European side, who narrowly lost to the feted Selecao in the opening stages of the 2006 World, threatened to tear up the script.
The edgy home side, who had won their previous nine matches, struggled to find their rhythm after a rousing crowd rendition of the national anthem in the new stadium.
Mateo Kovacic went close for Croatia, missing the suspended Bayern Munich player Mario Mandzukic, with a right-footed strike and Ivica Olic headed just wide of Julio Cesar's right post.
But the 18th-ranked side took the lead their early pressure deserved after 11 minutes as Olic, enjoying the space on the left, hit an inviting cross into the box.
Nikica Jelavic made contact and Brazilian defender Marcelo could not adjust his feet in time, watching in agony as the ball rolled into the net.