We investigate the effect of dissipation in a Bose-Josephson junction (BJJ) coupled to baths of bosons at its two sites. Apart from the dynamical transition due to repulsive interactions, the BJJ undergoes a quantum phase transition by increasing the coupling strength with the bath modes. We analyze this system by mapping to an equivalent spin model coupled to the bosonic modes. The excitation energies and fluctuation of number imbalance are obtained within a Holstein-Primakoff approximation, which exhibits vanishing of the energy gap and enhanced quantum fluctuations at the critical point. We study the dynamics of BJJ using a time-dependent variational method and analyze stability of different types of steady states. As a special case we study in detail the phase space dynamics of BJJ coupled to a single mode, which reveals diffusive and incoherent behavior with increasing coupling to the bath mode. The dynamical steady states corresponding to the π oscillation and self-trapped state become unstable when their oscillation frequencies are in resonance with the bath modes. We study the Josephson dynamics in the presence of an Ohmic bath with Gaussian noise to incorporate the thermal fluctuations and obtain the Josephson oscillation frequency and damping analytically. We also observe the transition to the symmetry-broken state for strong coupling as well as decay of π oscillation and a self-trapped state to the ground state due to dissipation. Variation of the phase fluctuation with temperature of the bath shows similar behavior as observed in experiment. Finally we discuss the experimental setup to study the observable effects of dissipation in BJJ.