  By using $N$-body and hydro simulations, we study the formation and evolution
of bars in galaxies with significant gas content focusing on the phenomenon of
the buckling instability. The galaxies are initially composed of a spherical
dark matter halo and only stellar, or stellar and gaseous, disks with
parameters that are similar to the Milky Way and are evolved for 10 Gyr. We
consider different values of the gas fraction $f =0-0.3$ and in order to
isolate the effect of the gas, we kept the fraction constant during the
evolution by not allowing the gas to cool and form stars. The stellar bars that
form in simulations with higher gas fractions are weaker and shorter, and they
do not form at all for gas fractions that are higher than 0.3. The bar with a
gas fraction of 0.1 forms sooner due to initial perturbations in the gas, but
despite the longer evolution, it does not become stronger than the one in the
collisionless case at the end of evolution. The bars in the gas component are
weaker; they reach their maximum strength around 4 Gyr and later decline to
transform into spheroidal shapes. The distortion of the stellar bar during the
buckling instability is weaker for higher gas fractions and weakens the bar
less significantly, but it has a similar structure both in terms of radial
profiles and in face-on projections. For $f=0.2,$ the first buckling lasts
significantly longer and the bar does not undergo the secondary buckling event,
while for $f=0.3,$ the buckling does not occur. Despite these differences, all
bars develop boxy/peanut shapes in the stellar and gas component by the end of
the evolution, although their thickness is smaller for higher gas fractions.
